Bash Read from standard input


Example

cat < file.txt

Output is same as cat file.txt, but it reads the contents of the file from standard input instead of directly from the file.

printf "first line\nSecond line\n" | cat -n 

The echo command before | outputs two lines. The cat command acts on the output to add line numbers.