Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by AJefferiss for Direct output from a command to a file including the original command, AND print in terminal

You could make use of the script command which will make a typescript file of everything printed to your terminal. It creates a forked shells and will record everything until that shell is exited.

$ script my_output
Script started on Tue 28 Nov 2017 09:46:15 AM UTC
$ whoami
ajefferiss
$ exit
Script done on Tue 28 Nov 2017 09:46:27 AM UTC

Then if I cat my_output I get the same output:

$ cat my_output
Script started on Tue 28 Nov 2017 09:46:15 AM UTC
$ whoami
ajefferiss
$ exit
exit

Script done on Tue 28 Nov 2017 09:46:27 AM UTC

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>