I can use herestrings to pass a string to a command, e.g.
cat <<< "This is a string"
How can I use herestrings to pass two strings to a command? How can I do something like
### not working
diff <<< "string1" "string2"
### working but overkill
echo "string1" > file1
echo "string2" > file2
diff file1 file2
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With