1

I want to email the file returned by the following command as an attachment (on RHEL/CentOS):

ls -1 $(hostname -s)*.xml | tail -n 1

For example, the command above returns server-20140430080511.xml and I want to then email that file to a recipient from the command line, all done in the one command (on one line) so that we can script/automate this process.

Can anyone suggest how to do this on a single line?

4

You can use uuencode:

uuencode server-20140430080511.xml abcdef | mail recipient@some.host

Where abcdef is the name the attachment will have in the email (which can of course be the same as the filename to encode, but it needs to be specified).

(On Ubuntu, the uuencode command is in sharutils, and mail e.g. in mailutils).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.