Dump Terminal Session to File

Dump terminal session to file?

If you want the whole contents of the terminal history:

In the gnome-terminal menu, Edit > Select All and then Edit > Copy. (Or use your favorite keyboard shortcut for the copy.)

Then paste anywhere.

If you want just part of the history, select with your mouse and then copy.

How to dump the entire GDB session to a file, including commands I type and their output?

If you want to log GDB's output, you can use the GDB logging output commands, eg.

set logging file mylog.txt
set logging on

If you want to redirect your program's output to a file, you can use a redirect, eg.

run myprog > mylog.txt

see the chapter on program IO in the GDB manual for more information

Save Screen (program) output to a file

There is a command line option for logging. The output is saved to screenlog.n file, where n is a number of the screen.
From man pages of screen:

‘-L’ Tell screen to turn on automatic output logging for the windows.

How to save terminal output automatically in shell script

Use javac foo.java > output.txt to capture the output of your command to the file output.txt.

This will however hide all output from you while it is compiling your module.

If you would like to see the output of your build in the terminal and at the same time capture the output into file output.txt you can use tee:

javac foo.java | tee output.txt

The tee program reads from stdin and writes everything into the specified file and also to stdout again.

How to redirect output to a file and stdout

The command you want is named tee:

foo | tee output.file

For example, if you only care about stdout:

ls -a | tee output.file

If you want to include stderr, do:

program [arguments...] 2>&1 | tee outfile

2>&1 redirects channel 2 (stderr/standard error) into channel 1 (stdout/standard output), such that both is written as stdout. It is also directed to the given output file as of the tee command.

Furthermore, if you want to append to the log file, use tee -a as:

program [arguments...] 2>&1 | tee -a outfile

Saving displayed output from terminal to file with a nice format

What you are doing can be done simply with:

ifconfig -a | grep  "inet\|lo\|eth\|wlan" >> filename.txt

or

grep  "inet\|lo\|eth\|wlan" <<<"$(ifconfig -a)" >> filename.txt

And the reason for the "different" output in your current code is because all the whitespaces are lost. If you do:

echo "$(ifconfig -a | grep  "inet\|lo\|eth\|wlan")" >> filename.txt

you wouldn't have that problem.

Linux Terminal: how to capture or watch other terminal session

If the other person is using the Linux console, you can use conspy.

How to save a ssh session's whole echo history over tty to a file?

You could use tee to read from stdin and stdout and redirect to a log file:

ssh user@server | tee ssh_session.out

Assuming that you know before making the connection that you want to log the session.



Related Topics



Leave a reply



Submit