books on zlib official

here-document and here-string in Bash and Fish

In Bash there are two well-known constructs named here-document and here-string. here-document is

wc << EOF
> one two three
> four five
> EOF
 2  5 24

and here-string is

bc <<< 5*4

here-document

You can write command followed by << EOF and then write (new lines too) until you write EOF on the new line. Of course you can type everything you want, not only EOF.

The content you write is piped to the command. It is similar to create file with these content or call echo:

echo -e "one two three\nfour five"|wc

here-string

The command get input what is written after <<<. This is useful if you want output of interactive command. Fish doesn’t support this construct but you can use echo the same way as in the here-document:

echo "5*4"|bc

More info about it is here: https://askubuntu.com/questions/678915/whats-the-difference-between-and-in-bash

Leave a Reply

Your email address will not be published. Required fields are marked *