Reputation: 6531
How can the directories on the level one can be listed in a tar.gz archive? E.g. \dir1\ \dir2\ \dir3\ \dir4\ \dir1\
Not \dir1\bla \dir1\bla2
Upvotes: 12
Views: 14940
Reputation: 86924
You can use the --exclude
option to exclude everything that's within a directory.
tar tfz archive.tar.gz --exclude '*/*'
Example:
[me@home]$ tar tfj CUnit-2.1-2-src.tar.bz2 | head -n5
CUnit-2.1-2/
CUnit-2.1-2/NEWS
CUnit-2.1-2/Makefile.am
CUnit-2.1-2/configure
CUnit-2.1-2/cunit.pc.in
[me@home]$ tar tfj CUnit-2.1-2-src.tar.bz2 --exclude '*/*'
CUnit-2.1-2/
Upvotes: 22