Reading Standard Input in a Bash Shell Script
I guess this is obvious to most people but it took me quite a while to dig it out on the internet. I wanted my bash script to be able to read from standard input like cat sourcefile.txt|bash myscript.bash
. It turns out the standard input can be read from /dev/stdin
. So if I wanted to sort
the standard input, myscript.bash would look like: sort /dev/stdin
I think this is probably basic UNIX knowledge but I’m not a programmer.