What does "-" mean in this linux command?

it is common to write stdin as dash (-).

even man cat mentions that:

With no FILE, or when FILE is -, read standard input.

and the manpage even has an example illustrating the use of dash and ordinary filenames (which is quite close to your original question, but includes the answer):

   cat f - g
          Output f's contents, then standard input, then g's contents.

- tells cat to read from stdin. This is quite common, a lot of apps read from stdin if you pass - to them.

Some apps use - as stdout.

Here is an example of downloading blender and instead of writing it to a file we write it directly to stdout and pipe it to tar, which expands it on the fly during download.

wget -c https://download.blender.org/source/blender-2.90.1.tar.xz -O - | tar -xzv

Here the -O - tells wget to write directly to stdout


$ echo 'Text through stdin' | cat - file.txt

- tells cat to read from standard input, in this case, from the pipe, i.e, what echo 'Text through stdin' outputs.

Tags:

Linux

Cat