Save current terminal scrollback to file?
After a bit of playing around I've discovered that you can:
triple-click
the last line- hit shift + home
- shift +
click
first line - copy with ctrl + shift + c (or
right-click
> 'Copy')
Now paste it into a text file ...or, using xsel
you can shove your clipboard into a new file by just popping open a new tab and doing:
xsel -o > out.txt
(To install xsel
do sudo apt-get install xsel
)
script
command is appropriate when you want to save a terminal session to a file and display it later. When you call script
it launches your shell, and when you are done, just type in exit. Everything will be in typescript
file unless you specify otherwise.
For instance,
xieerqi:$ echo "Hello, Karl Wilbur"
Hello, Karl Wilbur
xieerqi:$ date
2015年 10月 27日 星期二 11:38:15 MDT
xieerqi:$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 115247656 80939384 28430924 75% /
none 4 0 4 0% /sys/fs/cgroup
udev 2914832 4 2914828 1% /dev
tmpfs 585216 1100 584116 1% /run
none 5120 0 5120 0% /run/lock
none 2926072 328 2925744 1% /run/shm
none 102400 52 102348 1% /run/user
xieerqi:$ exit
Script done, file is typescript
xieerqi@eagle:~$ cat typescript
Script started on 2015年10月27日 星期二 11时37分55秒
xieerqi:$ echo "Hello, Karl Wilbur"
Hello, Karl Wilbur
xieerqi:$ date
2015年 10月 27日 星期二 11:38:15 MDT
xieerqi:$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 115247656 80939384 28430924 75% /
none 4 0 4 0% /sys/fs/cgroup
udev 2914832 4 2914828 1% /dev
tmpfs 585216 1100 584116 1% /run
none 5120 0 5120 0% /run/lock
none 2926072 328 2925744 1% /run/shm
none 102400 52 102348 1% /run/user
xieerqi:$ exit
Script done on 2015年10月27日 星期二 11时38分18秒
There may be control characters in the typescript file though ,such as from the ls
comand, so use cat typescript | col -b > outputfile.txt
command to redirect clean output to file