Tuesday, October 22, 2013

Send a file as an attachment in linux

Have a file you need sent as an attachment, not an inline message?  Use mutt and this example command.  the trick is the "--" which

The meaning of the double-dash "--" is:
-- Used with a Bash builtin, it means the end of options to that particular command.
-- The double-dash is also used in conjunction with set.


echo "This is the body" |mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com

NOTES:
"-" a single dash can be used for:
-- redirection from/to stdin or stdout [dash]
-- Example: cat -
-- Example: tar cf - .
-- 
(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xpvf -)
-- The "-" can be used to pipe stdout to other commands. This permits such stunts as prepending lines to a file.
-- example: grep Linux file1 | diff file2 -