[Shell command] Prepend text to a file's contents with echo and cat

Created on November 28, 2026

You can combine echo and cat to output text before the contents of a file.

Example

Create a file named dummy.txt with the following contents.

two
three

To place one before the contents of the file, use echo to write one and pipe the result to cat. Use - as the first argument to cat to represent standard input.

echo "one" | cat - dummy.txt

The command produces the following output.

one
two
three
Shell command