home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 45.23 The Ins and Outs of Redirected I/O Loops Chapter 45
Shell Programming for the Initiated
Next: 45.25 Shell Scripts On-the-Fly from Standard Input
 

45.24 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 zip script:

A:

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


Previous: 45.23 The Ins and Outs of Redirected I/O Loops UNIX Power Tools Next: 45.25 Shell Scripts On-the-Fly from Standard Input
45.23 The Ins and Outs of Redirected I/O Loops Book Index 45.25 Shell Scripts On-the-Fly from Standard Input

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System