Published on 2012-09-12 by John Collins. Please follow me on Twitter for more:
On occasion I find myself needing to quickly send a file to myself from a live system to another system, where I can then do some offline analysis (for example, on a log file or a network trace file from tcpdump).
If the file in question is small, you can achieve this quickly by simply emailing it to yourself via the mail command in Linux. Here is an example where I am emailing a .pcap file from a network trace to my email account:
$ mail -s 'Network trace test' -a /home/john/trace1.pcap email@example.com
The -s flag is the subject line of the mail we are going to send, while the -a flag points to the file that we are going to attach (it's usually a good idea to compress these first if the file is large). When you run this command, it will wait for input: this input from you will become the body of the email. When you are ready, press ctrl-d to send it.