Using two here strings Using two here strings shell shell

Using two here strings


You can't use two herestrings as input to the same command. In effect, the latest one will replace all others. Demonstration:

cat <<< "string 1" <<< "string 2" <<< "string 3"# only shows "string 3"

On the other hand, if what you want is really diff two immediate inputs, you can do it this way:

diff <(echo "string 1") <(echo "string 2")


You can simply concatenate the two strings:

cat <<< "string1""string2"

(not the lack of space between the two). The here string now consists of a single word whose contents are the contents of the two strings.