I have been looking for lesser known commands that reads their standard input in special cases(missing arguments , for example).
I'm thinking "cat" or maybe other command would fit here.
I have been looking for lesser known commands that reads their standard input in special cases(missing arguments , for example).
I'm thinking "cat" or maybe other command would fit here.
There are a few cases that come to mind:
For missing arguments, cat
is a useful example. Likewise grep
, sed
.
The special argument "-" is used in several programs to tell it explicitly to read from the standard input. You can find discussion (with examples) in these:
For the case where the standard input is not a terminal—offhand, the cases I'm familiar with are less known:
-v
(verbose) option when doing this shows progress, e.g., a "." for each fileFor special arguments:
--gauge
which reads data from the standard input. Also --input-fd
tells it which file descriptor to use as its input for pipes.-stdin
telling it to interpret the standard input as html. Otherwise, it accepts configuration options on the standard input, e.g., using -get_data
or -post_data
.
cat
command will read from stdin either when there are no arguments or when it encounters-
in the list of files to process. Neither seems a particularly special case to me. – Chris Davies Oct 24 '15 at 11:59-
or, at worst,/dev/stdin
). It's perfectly normal and not in the least bit unusual or "special case". There has been an unfortunate trend in recent years to write tools that are incapable of this (looking at YOU, python programmers) but they're still rare. – cas Oct 24 '15 at 12:26