I’m struggling to achieve folowing without temp. files.
#!/bin/bash
tar ztf "$1" | sort > tmp1
tar ztf "$2" | sort > tmp2
comm -1 -3 tmp{1,2}|while read line; do echo -e "$1: $line\n"; done
comm -2 -3 tmp{1,2}|while read line; do echo -e "$2: $line\n"; done
rm tmp{1,2}
how to do this without tmp files ?
Since you are using each temp file twice, the answer is almost certainly no. However, if you modify the script to use a single command (e.g.
commby itself, ordiff) then the following should work:This uses process substitution.
(Also, just as an aside, one should use
mktempto create temporary files)