read does not write to standard output.
$ cat test.sh #!/bin/bash read -p "type a key and Enter" key echo "the key was $key" $ ./test.sh type a key and Enterx the key was x $ ./test.sh | tee file type a key and Enterx the key was x $ cat file the key was x
Trying it without a script...
$ read -p "type a key and Enter" key | tee file type a key and Enterx $ cat file $
read command is described here. A brief description: "Read a line from standard input".
Information on the pipe,
|, from The Linux Command Line (2nd Internet Edition) by William E. Shotts follows.
Using the pipe operator "|" (vertical bar), the standard output of one command can be piped to into the standard input of another:
command1 | command2
From the man page for
tee is this description:
read from standard input and write to standard output and files
The man page for
tee is at this link.
Where is the list of all the other examples of programs that write to the console but actually do not use standard output, or in the absence of such a list, what is the general rule for knowing when a program that writes to the console is not using standard output?
read violates the Principle of Least Astonishment.