Friday, May 11, 2012

What is "Here-Document"?


The Unix shell has got a facility "here-document" which allows you to put input under a command, instead of in a separate text file and feed it into the program.
This is done by placing a "<<" and a character string after the command.  Then, every line after the command is interpreting as free-form text to be fed into the command, until a line is hit that has the character string.
For example,
cat <<!
This is an example of text taken literally except that variables are expanded where their variable names appear.
!
would behave exactly like
cat < file
where the file would contain:
This is an example of text taken literally except that variables are expanded where their variable names appear.

No comments :