If you put filenames on the command line, a typical UNIX command will read those files. With no filenames, the command will read its standard input. How can you make the command read both files and standard input? Some UNIX systems, and utilities such as
gawk
(
33.12
)
, support a special name like
/dev/stdin
(
13.1
)
. Some older UNIX commands, like
cat
(
25.2
)
and
diff
(
28.1
)
, will accept a "filename" of
-
(dash). There's not actually a file named
-
; it's just a shorthand for "read standard input."
NOTE: This syntax might change in the future.
For instance, here's how to compare two files on different computers. The
rsh
snooze
cat
bin/aprog
command sends a copy of the file
bin/aprog
from the remote host
snooze
down the pipe here on the local computer.
diff
compares the local file
aprog.new
to the standard input from the pipe:
rsh |
%
|
---|
For more examples, see articles 9.11 and 13.7 .
-