36.17. A 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 stdin-demo script: while read word do echo $word | sed s/foo/bar/ done If run as sh stdin-demo, it will read from your terminal, replacing foo with bar. If run as sh < stdin-demo, it will exit right away, since after reading the script, there's no input left. -- CT Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|