26

Having two different .tar.gz files: The second .tar.gz is the subset of first .tar.gz.

I need a single line command to find the missing files in second .tar.gz.

E.g.:

1.tar.gz file list:

1.jsp
2.txt
3.htm

2.tar.gz file list:

1.jsp
3.htm

output should be:

2.txt
codeforester
  • 39,467
  • 16
  • 112
  • 140
Ganesan MP
  • 387
  • 1
  • 4
  • 10

1 Answers1

45

Just list the contents and do diff:

diff <(tar -tvf 1.tar.gz | sort) <(tar -tvf 2.tar.gz | sort)
Community
  • 1
  • 1
P.P
  • 117,907
  • 20
  • 175
  • 238
  • I get "invalid tar magic" with `tar -tvf 1.tar.gz` in bash. When I do `tar -tzvf 1.tar.gz` it works. – FlexMcMurphy Jan 04 '21 at 01:24
  • @FlexMcMurphy Looks like your tar doesn't support all features. Is it a busybox (which is [known to lack this](https://unix.stackexchange.com/a/249357/72606)? – P.P Jan 04 '21 at 08:57
  • 1
    That's exactly what it is! I'm using Busybox on OpenWrt. I'm glad I figured out how to modify your command to my more limited environment. – FlexMcMurphy Jan 05 '21 at 21:42