Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 : enter image description here

I have tried to convert file to dos using todos, vim and also tried with dos2unix but it skipping file dos2unix: Skipping binary file.

share|improve this question
    
please recreate the screenshot with a terminal which is not transparent –  lesmana Aug 15 '13 at 17:43

1 Answer 1

up vote 3 down vote accepted

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 terminal.

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.

using col

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

commandlinefu

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

References

share|improve this answer
    
Thanks, it's remove 99% junk character, but still remain one i.e ^G –  Rahul Patil Aug 15 '13 at 16:53
    
What if you run the file out through cat, cat typescript? –  slm Aug 15 '13 at 16:54
    
when I used cat typescript, It's Output OK, what I want, but when I redirect Output to another file, then junk character appear into that file.. –  Rahul Patil Aug 15 '13 at 16:56
    
@RahulPatil - how about the perl option? –  slm Aug 15 '13 at 16:58
    
Thanks , that last update solve my problem . :) –  Rahul Patil Aug 15 '13 at 16:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.