0

I have the following command:

wash -n <groups> <<EOF echo hi echo bye <<BYE <commands> exit 0 BYE exit 0 EOF <commands> 

where <groups> are some groups and <commands> are commands. I don't understand what <<EOF and <<BYE mean? Is it some label which the script jumps in case fails? What does this script do?

2
  • It is called a "here" document. It allows you to add stdin alongside the command in a script. Commented Apr 5, 2021 at 16:11
  • See also the here-document tag. Commented Apr 5, 2021 at 16:57

2 Answers 2

2

It is a feature named "here document". Basically it means that the text between <<whatever and whatever are presented to the standard input of the command. In your case, the stdin seen by the first command is,

echo hi echo bye <<BYE <commands> exit 0 BYE exit 0 
2
  • So if <commands> is echo inside, I get hi and the bye. It does not run the command echo inside. Not sure I understood the flow. Commented Apr 5, 2021 at 16:41
  • @vesii The here-document does not matter much in this example as echo does not read from its standard input stream. The contents of the here-document is simply discarded. Commented Apr 5, 2021 at 16:55
-1

tl;dr: command << TEXT: the string TEXT is treated as end-of-file.

I tested, and it seems to be like this: When you do:

% command << TEXT 

csh reads the standard input, and when it catches TEXT, the full stdin before TEXT is redirected to command. (TEXT has to be on a separate row to work)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.