What is heredoc in shell ?
A heredoc is a way to provide input to a command , by just writing it along the command , as in :
$ cat <<delm
> hello world
A heredoc is not about providing options or arguments to a command . The command must actually be able to read from standard input , so for example writing the earlier example while using the
echo command instead of
cat , will just print a new line , as
echo does not read from standard input .
$ echo <<in
> Hello world
In a heredoc interpolation or expansion takes place , for example ,
$ cat <<in
This can be prevented , by quoting the first delimiter in a heredoc string , using either
\ , as in :