For example, I run the top command and store it to a file in Linux, after that I open that file in Windows it contains some gibberish. Here is the file viewed in Notepad++:
The option to convert to UTF-8 in Notepad++ doesn't work.
How can I read that file in Windows? I tried using dos2unix but it doesn't work and gives the error:
dos2unix: Binary symbol 0x1B found at line 1
Edit: Trying the sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' file.txt command gives the expected output but only in the terminal

topnot to print these characters in the first place. Some tools modify their behavior automatically if their stdout is not a terminal. It seemstopdoes not do this. Use-b, e.g.top -b -n 1 >output; seeman 1 top. In general, if sometroublesome_programprovides no option to turn ANSI escape sequences off, you can try passingTERM=dumbin the environment, e.g.TERM=dumb troublesome_program. – Kamil Maciorowski Apr 19 '23 at 09:26