Reputation: 23
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 ?
Upvotes: 2
Views: 1053
Reputation: 102106
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. comm
by itself, or diff
) then the following should work:
diff <(tar ztf "$1" | sort) <(tar ztf "$2" | sort)
This uses process substitution.
(Also, just as an aside, one should use mktemp
to create temporary files)
Upvotes: 4