Sometimes, you may want to add header or footer information to a stream in a pipeline, perhaps read from another file. One straightforward way of doing this is using cat for its intended purpose of concatenating streams of input.
Normally, cat combines all of the filenames specified in its arguments and writes them to standard output, in the same order they were specified:
$ cat myfile1 myfile2 myfile3 > myfiles.combined
We can use the special value of a single hyphen (-) anywhere among the cat filename arguments to denote that any standard input to cat should be added at that point. For example, if we had a generate-html command that generated the body of an HTML document, we might want to add the headers with the <!DOCTYPE html>, <html>, <head>, <body>, and other tags in header.html at the top, and the closing tags, such as </body> and </html>, in footer.html at the end. We could combine them with one pipeline using the - representation for the standard input:
$ generate-html <p>Here is the content!</p> $ generate-html | cat header.html - footer.html <!DOCTYPE html> <html> <head> <title></title> </head> <body> <p>Here is the content!</p> </body> </html>
Note that the single hyphen word (-) syntax is not a special value to Bash itself; it's just a conventional way for individual programs to specify the standard input stream on the command line. It's supported for many of the standardized POSIX tools, such as cat. For some other commands, you might need to explicitly use the pseudo-device file, /dev/stdin, in place of the hyphen.