xx.txt

Cat magic - end of input

When "cat> xx.txt <EOF" is entered on the command line, further input from cmdline goes into the xx.txt file until EOF is written. EOF is not a sacred word here, if the command was instead cat> xx.txt <<BBB then the cmdline input goes to xx.txt until BBB is written. I don't know what is the reason (<end_of_input_sequence). The Cat man page explains little. I've only seen this in scripts, etc.

+2


source to share


3 answers


This is a feature of the shell, not cat

- so you won't find it in the manual cat

.



It is known as the "Here" document - see this Advanced Bash-Scripting Guide page for any documentation.

+9


source


It's called here . I believe it first appeared in wrappers, but some programming languages ​​like Perl, Ruby and PHP also implement this style.



+7


source


This syntax is called Here Document (scroll a little to find it).

This does not apply to any team, not a cat more than any other team; and it can be found in the shell man; for example man bash

:

3.6.6 Here Documents

This type of redirection instructs the shell to read input from the current source as long as a line containing only a word (no trailing spaces) has been seen. All lines are read up to this point then used as the standard input for the command.

(Not a complete quote - there is more to read in a person)


BTW, this is a syntax that has been reused in some programming languages ​​like PHP; -)

+4


source







All Articles