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 want to pipe the output file from the command line audio tool SoX into the email tool mutt.

What I want to do is something akin to this:

sox /Users/someUser/Desktop/input.mp3 output.mp3 | mutt -s "someSubject" -a [output-from-sox]

The thing I don't know how to do is wrapped in square brackets.

I'm a UNIX novice so any hints would be highly appreciated.

share|improve this question
You don't mean sox /Users/someUser/Desktop/input.mp3 output.mp3 ; mutt -s "someSubject" -a output.mp3 do you? You want to send the command line output? – Daniel Beck May 17 '11 at 7:56
I want sox to output the mp3-file and mutt to email that file. I don't know if my pipe approach is the right way to do this :S – timkl May 17 '11 at 8:08
Since your sox call writes output.mp3, why don't you just use that one like I suggested and delete it after sending? In case sending fails or something like that, you'll still have the file to try again. – Daniel Beck May 17 '11 at 8:09
Instead of using ; to separate the commands, use && so that the second command only runs if the first one was successful. – Majenko May 17 '11 at 8:11
It's worth to add that common practice is denoting stdin/stdout as single dash -, whenever input/output file arguments are considered. See example in cat(1) manpage for instance. – przemoc May 17 '11 at 10:31
up vote 2 down vote accepted

A pipe in a Unix-like operating system is for running one program, taking its standard output (which would otherwise go to the screen) and using it as input to another program (in place of its standard input which would normally come from the keyboard).

It seems like what you want to do is have one program output to a file, and then have another program use the file as input. You don't need a pipe for that.

To run one program after another one finishes, all on one command line, use ;. For example:

sox /Users/someUser/Desktop/input.mp3 output.mp3 ; mutt -s "someSubject" -a output.mp3

Unix command line programs output an "exit status" or "return code". Most programs output 0 to indicate that they did their thing successfully, or some other value if there was a problem. If your first command is like this, use && in place of ; to only run the second command if the first one was successful. For example:

sox /Users/someUser/Desktop/input.mp3 output.mp3 && mutt -s "someSubject" -a output.mp3
share|improve this answer
Really helpful explanation, thx a bunch! :) – timkl May 17 '11 at 8:17

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.