3

I am redirecting the output of the terminal to a file using:

Command > File.txt

but the contents of the file appear like this:

enter image description here

What is the problem? How can I make them appear normal?

muru
  • 207,228
Adam
  • 2,738

3 Answers3

3

The command you're executing (minicom) is using "VT100 Escape Sequences" to do cursor positioning.

To remove the characters listed above, pipe the file through

sed -e 's/^[\[[0-9][0-9];[0-9][0-9]H//'
#         ^^ actual ESCape

I got the Escape by typing Ctrl-VEsc.

waltinator
  • 37,856
1

Those are terminal escape sequences, to be interpreted by the terminal driver. As the output from the program is being saved to a file, the (minicom) program rather erroneously dumping the escape sequences too without checking where it's STDOUT is going.

To get rid of the escape sequences, using sed to remove the lines that contain 23;80H, dry-run:

sed '/23;80H/d' file.txt

Modification:

sed -i '/23;80H/d' file.txt

If you wish to keep a backup with an extension e.g. .bak, do:

sed -i.bak '/23;80H/d' file.txt
heemayl
  • 93,925
0

This happens because you haven't set character encoding of output file to UTF-8.

In case you cannot change /etc/* files,

you can manually set the gnome-terminal menu Terminal|Set Character Encoding to Unicode(Utf-8)

Answer obtained from this stackoverflow link