Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

$ path/to/targetdir/audio.gsm audio.gsm | mail

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
up vote 0 down vote accepted

You could to the following:

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

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


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.