Bash – Elegant way of diff’ing two variables

bashdiff()here-stringio-redirection

I have $a and $b. I want to run diff on those.

The best I have come up with is:

diff <(cat <<<"$a") <(cat <<<"$b")

But I have the district feeling that I am missing a clever Bash syntax to do that (as in "Why don't you just use foo?").

Best Answer

echo. Clearly less weird.

#!/bin/bash

a="`seq 10`"
b="`seq 0 11`"

diff <(echo "$a") <(echo "$b")
Related Question