0

Belows are the code what I want to understand:

#!/bin/bash
cat > pl.gp <<EOF
...
CONTENTS
...
EOF

The resultant of this shell script gives a pl.gp file which contains every texts before EOF meets. Does anyone help me understand this powerful redirection usage of shell?

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
user4914499
  • 344
  • 1
  • 3
  • 12

1 Answers1

1

This is called a heredoc.

Everything from the <<EOF up to the following EOF token is fed into the cat process on its stdin. cat (by its nature) will then dump it out into the nominated file via stdout redirection (the > operator)

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440