1

I'm looking for a way to log all the input and output on terminal during a session, but I can't properly find an answer to do it. This this post suggested using script screen.log to do so and it seems perfect, that's EXACTLY what I needed. However, this generate a file with very weird characters as shown in this picture (screenshot from VIM of the file). I have also tried to open it with Sublime Text and the weird characters are there as well.

I have tried this method on two different machines, one using WLS 2 with Ubuntu 20.04.1 LTS (focal) and the other using WLS 1 with Ubuntu 18.04.2 LTS (bionic). Both had the same result.

Is there any way to do exactly this without the weird characters?

Many thanks

Jn Coe
  • 11
  • Those are control sequences - they are included in the typescript file so that programs can exactly reproduce what you saw on screen. Try opening the file in less rather than vim – steeldriver Oct 15 '20 at 16:09
  • That actually didn't work but thanks to your tip I was able to find a solution, just type cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' \ | col -b > typescript-processed where typescript is the name of the original log and type-script-processed is the name of the output file. Thanks! – Jn Coe Oct 15 '20 at 16:52

1 Answers1

0

As pointed out by Steeldriver, those are control sequences. After doing some google with this term I was able to find this post with a solution: Just run the script command as usual After saving the file, remove the junk characters with this command:

cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' \
             | col -b > typescript-processed

Worked for me

Jn Coe
  • 11