Artificial intelligent assistant

Pass BASH array to diff like file contents I have two `bash` arrays, say: arr1=( 1 2 3 ) arr2=( 1 2 A ) and I want to compare them using `diff`. How could I pass the arrays as if they were the contents of a file? I tried a few variations, but all failed: diff -y <$( echo ${arr1[@]} | tr ' ' '\n' ) <$( echo ${arr2[@]} | tr ' ' '\n' ) diff -y <${arr1[@]} <${arr2[@]} diff -y $(<${arr2[@]}) $(<${arr1[@]}) diff -y <<<"$( echo ${arr1[@]} | tr ' ' '\n' )" \ <<<"$( echo ${arr2[@]} | tr ' ' '\n' )" Desired output would be the expected from `diff -y`, which I get if I store the arrays into files a and b: diff a b 1 1 2 2 3 | A (less spaces for readability) I would like to avoid writing intermediate files for speed reasons, although I am aware of `tmpfs` pseudo files as RAM-based workaround.

Using `printf` and process substitution


diff -y <(printf '%s\
' "${arr1[@]}") <(printf '%s\
' "${arr2[@]}")
1 1
2 2
3 | A

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 40d6097abd680620af01cc3c610e23d4