Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using uuencode and mail to do basic file attachments to an email.

$ path/to/targetdir/audio.gsm audio.gsm | mail user@mail.com

This works but my problem is I am trying to find a way to recursively attach all files in targetdir from the example above.

I am familiar with some shell scripting basics so I wouldnt be opposed to a solution using some shell scripting.

Thanks in advance for any help regarding the issue.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You could to the following:

(cd path/to/targetdir; tar czf - .) | uuencode archive.tar.gz | mail user@mail.com

The cd will change to the targetdir. The tar command will archive everthing in . (then the targetdir) and gzip it (option z) and write it to stdout (option f, "-" refers to stdout). uuencode with only one parameter reads its data from stdin instead of a file. The archive.tar.gz is the decode name.

share|improve this answer
    
This works really well. I appreciate the explanation of option flags too. Thanks –  BryanK Oct 23 '13 at 18:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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