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.
Pass BASH array to diff like file contents
bash;io redirection;diff;array
Using printf and process substitutiondiff -y  <(printf '%s\n' ${arr1[@]})  <(printf '%s\n' ${arr2[@]})1                                                               12                                                               23                                                             | A