Shell Can Read a Script from its Standard Input, But...

Q: What is the difference between sh < file and sh file?

A: The first way keeps the script from reading anything else from its input. Consider the zip script:

while read word do echo $word | sed s/foo/bar/ done

If run as sh zip, it will read from your terminal, replacing foo with bar. If run as sh < zip, it will exit right away, since after reading the script, there's no input left.

- CT in net.unix on Usenet, 29 December 1984