next up previous 405
Next: Discarding text output
Up: Dealing with Files
Previous: Choosing columns by name


Reading from dynamic text files

You can also read from a text file created dynamically from within your script.

     ./doubleword < mynovel.txt

     myprog <<BAR
     320 512
     $nstars
     `wc -l < brightnesses.txt`
     testimage
     BAR

     commentary <<\foo
        The AITCH package offers unrivalled facilities.
        It is also easy to use because of its GUI interface.

                   Save $$$ if you buy now.
     foo
Command ./doubleword reads its standard input from the file mynovel.txt. The «word obtains the input data from the script file itself until there is line beginning word. You may also include variables and commands to execute as the $, \, and ` ` retain their special meaning. If you want these characters to be treated literally, say to prevent substitution, insert a \ before the delimiting word. The command myprog reads from the script, substituting the value of variable nstars in the second line, and the number of lines in file brightnesses.txt in the third line.

The technical term for such files are here documents.


next up previous 405
Next: Discarding text output
Up: Dealing with Files
Previous: Choosing columns by name

C-shell Cookbook
Starlink Cookbook 4
Malcolm J. Currie
2006 November 26
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council