$ echo 1 | (echo 2 && cat) 2 1
I am pretty sure that there is a nicer solution, but this should do.
Either use what Claudius said or make your own:
#!/bin/sh echo -en "[email protected]" cat -
$ echo "Splendid SUPANINJA! Let's do it!" |\ prepend "Subject: Venetian Snares\n" Subject: Venetian Snares Splendid SUPANINJA! Lets do it!
This is inspired by Claudius answer.
If you don’t want a break return between your outputs, add the
-n param. This will look like:
$ echo 1 | (echo -n 2 && cat)
Which will give:
You can prepend to piped output using process substitution:
$ echo "mail content" | cat <(echo "Subject: All that matters") - Subject: All that matters mail content
From the pieces I’ve gathered… you could do something like this:
echo "Subject: All that matters `echo "mail content"`" | sendmail [email protected]
Notice that I did not close the quotes on the first line… because not all shells translate the
\n into a newline character… but I have yet to find one that wont process an actual newline inside the quotes.
When a command is enclosed in the ` character, it will be executed and the output will be injected in-place. Keep in mind that this bit of code is a bit dangerous as it is possible to inject additional commands inline that could easily compromise your system…
****edit**** Following advise of Claudius, a cleaner option would look like this:
echo -e "Subject: All that matters \n $(echo "mail content") |sendmail [email protected]
Even with that template, it could be exploited.