czwartek, 12 stycznia 2012

Here tag

"Here Tag" - how to enter multi-line entry to commands.
e.g.

cat >file <<HERE
> ab asd ew
> as ggs sfdw er we
> HERE

Entry "<<HERE" tells what word is finishing entry. The word is arbitrary (e.g. EOF, STOP, blahblah, ...). The tag is not written to file.
What is important to notice is "<<" and not "<".
Multi-line input finishes when tag is entered, but tag must be only input in line (i.e. without spaces, other characters). Tag can be entered as part of text in line and in that case not considered "here tag".
Here tags are available in bash, perl, awk and others.

Brak komentarzy:

Prześlij komentarz