Reputation: 1161
I have two archive 1.tar.gz (containing hello.txt) and 2.tar.gz (containing hello.txt and helloworld.txt).
I would get the diff between this two tar.gz. The output should be helloworld.txt.
I've tried with tis command :
diff <(tar -tvf 1.tar.gz | sort) <(tar -tvf 2.tar.gz | sort)
but the output was wrong. I've got this result :
< drwxr-xr-x user/user 0 2016-12-09 23:29 1/
< -rw-r--r-- user/user 344 2016-12-09 23:29 1/hello.txt.gpg
---
> drwxr-xr-x user/user 0 2016-12-09 23:27 2/
> -rw-r--r-- user/user 344 2016-12-09 23:27 2/hello.txt.gpg
> -rw-r--r-- user/user 363 2016-12-09 23:27 2/helloworld.txt.gpg
Upvotes: 1
Views: 2034
Reputation: 2187
This also works:
$ diff <(tar -tvf 1.tar.gz | rev | cut -d\/ -f1 | rev) <(tar -tvf 2.tar.gz | rev | cut -d\/ -f1 | rev)
1a2
> helloworld.txt.gpg
Further explanation:
The following: | rev | cur -d\/ -f1 | rev
is a quick way of getting just the filename out of a full path.
Upvotes: 2