0

I use this command and get an input prompt. I found it in an auto-ftp script.

$ <<!
>

I'd like to know its name and, how to use it.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
syxbyi
  • 141
  • 1
  • 6

1 Answers1

2

<< followed by any string means read the input until this string, and output all of this to the standard output.

So, you will find:

<<EOF
Hi,
This is some plain text.
EOF

Most of the time, there is a command before <<. This means: read the input and send it to the stdin of the command.

So you will find, for instance:

cat <<EOF 1>&2
This text is written to the stderr.
EOF

But you could write:

<<EOF 1>&2
This text is written to the stderr.
EOF

The same way, you can sort text:

sort <<EOF
A
C
D
B
EOF

to get A B C D in this order.

Finally, you can use this to pipe to another command:

<<EOF | tr a-z A-Z
This is some text. Yes.
EOF

to get:

THIS IS SOME TEXT. YES.
Alexandre Fenyo
  • 4,526
  • 1
  • 17
  • 24