cat > $FILE_NAME << EOF - Explanation of the inner workings

685
Ely

I know what this one does, I learned "pattern like" and just works.

I also know:

  • that > is a redirect to a file
  • that << is also a redirect to file see below
  • EOF is just a placeholder, when detected the file is closed

Can someone explain the inner workings of those instructions? Why does that work ?

Correction: the use of ´<<` is described in the man page of bash as:

<<[-]word here-document delimiter 

So it is the current source that is read from, which I think is stdin. Could someone decompose this into smaller chunks, that I can understand?

I think delimiter corresponds to EOF in my example, right?

And here-document is probably the text I type in in stdin, right?

I fail to see what is word.

0
`<<` - это _не_ редирект из файла. `< John1024 8 лет назад 1
Существует множество ссылок на использование оболочки в Интернете (и некоторые из них четкие и точные). Начните с чтения * самого следующего абзаца * `bash (1)` после блока, который вы цитировали; также проверьте [Что такое операторы управления и перенаправления оболочки?] (http://unix.stackexchange.com/q/159513/23408) (здесь, на Stack Exchange). Пожалуйста, проведите собственное исследование и дайте нам знать, если что-то конкретное трудно понять. Scott 8 лет назад 1
Ваша ссылка идеальна. Использование двух разных идентификаторов «слово» и «разделитель» сбивало с толку, они на самом деле одинаковы. Благодарю. Ely 8 лет назад 0

0 ответов на вопрос