What is the easiest – and preferably most portable – command I can use to email a single file as an attachment a *nix shell?
Unix – Easiest Way to Email File via Command Line
command-line-interfaceemaillinuxunix
command-line-interfaceemaillinuxunix
What is the easiest – and preferably most portable – command I can use to email a single file as an attachment a *nix shell?
Best Answer
Assuming it's a binary attachment:
uuencode [filename] [filename] | mail -s [subject] [recipient address]
You don't need to bother with the UUencoding if it's just a text file, eg:
mail -s [subject] [recipient address] < [filename]
Most *NIXes have mail and uuencode, so this should work pretty much anywhere.