1

Send a file by email as attachment

uuencode /var/log/messages messages.txt | mailx -s "/var/log/messages on $HOST" me@example.com

May 26, 2013bashoneliners

Explanation

  • uuencode /var/log/messages messages.txt -- the first parameter is the file to attach, the second is the filename to use for the attachment
  • mailx -s subject emailaddress -- takes standard input as the content of the email