Linux – Prefix standard output before piping to a command

bashlinuxsedshellstdout

On Linux (Debian), how can I prefix the standard output of a command with one or several lines before piping it to a second command?

This is for mailing the output of a command using sendmail like so:

pflogsumm <args> | sendmail <address>

I cannot specify a subject line this way since sendmail extracts header fields from the input it is fed. I thus want to prefix the pflogsumm output using sed.

Thank you.

/David

Best Answer

You can use a subshell. You can send output from anything you want, and it will all go out through the pipe.

(cat /foo ; echo bar ; pflogsumm <args> ) | sendmail <address>