Bash Here documents and here strings Here strings


Example

2.05b

You can feed a command using here strings like this:

$ awk '{print $2}' <<< "hello world - how are you?"
world

$ awk '{print $1}' <<< "hello how are you
> she is fine"
hello
she

You can also feed a while loop with a here string:

$ while IFS=" " read -r word1 word2 rest
> do
> echo "$word1"
> done <<< "hello how are you - i am fine"
hello