I’m Using Unix
script command to record everything which is output to the terminal and place it in a log file. but when I see recorded file, it also include Junk Character.
So how to record terminal activity without Junk Character.
Output Example :
I have tried to convert file to dos using
vim and also tried with
dos2unix but it skipping file
dos2unix: Skipping binary file.
Here is Solutions:
We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.
Not sure if you’ll be able to get rid of those easily. From the
script man page:
Certain interactive commands, such as vi(1), create garbage in the
typescript file. Script works best with commands that do not
manipulate the screen, the results are meant to emulate a hardcopy
The above output you’re showing are the escape codes which produce the colored output in your terminal along with what looks to be someone hitting the backspace after making some corrections to typos.
I did find this on SuperUser which makes use of the
col command to cleanup the output:
$ col -bp typescript | less -R
If that doesn’t work you can try this variant too:
$ col -bp < typescript
I found this solution on commandlinefu.com which uses Perl and col together.
$ cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' \ | col -b > typescript-processed
Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂