Reputation: 75
I need to list the folder/files inside a certs.tar.gz
which is inside file.tar without extracting them.
[root@git test]# tar -tf file.tar
./
./product/
./product/.git/
./product/.git/refs/
./product/.git/refs/heads/
./Release/add_or_modify.sh
./certs.tar.gz
[root@git test]#
Upvotes: 6
Views: 15429
Reputation: 3244
You may want to use and condition:
tar -xf abc.tar "abc.tar.gz" && tar -ztvf abc.tar.gz
Explanation:
For listing of files we use
If file is of type tar.gz:
tar -ztvf file.tar.gz
If file is of type tar:
tar -tvf file.tar
If file is of type tar.bz2:
tar -jtvf file.tar.bz2
You can also search for files in any of the above commands. e.g:
tar -tvf file.tar.bz2 '*.txt'
For extracting files we use
tar -xf file.tar
In these commands,
Upvotes: 14