here 字符串

Version >= 2.05b 以上

你可以使用此处的字符串来提供命令,如下所示:

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

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

你还可以使用 here 字符串提供 while 循环:

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