Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching within a TAR file

Status
Not open for further replies.

Eddiefdz

IS-IT--Management
Mar 20, 2002
273
US
Hello,

I am looking for a particular file that can be anywhere inside a couple of hundred tar files. So what I need to do is be able to search for that file name within those tar files without having to decompress the tarfiles and searching manually. Is there any way to do that in linux.

Thanks

Eddie Fernandez
CCNA, Network+, A+, MCP
 
Code:
for file in tarfiles* ; do tar tvf $file | grep -q filename && print $file ; done
You would have to use tzvf if they are compressed with gzip, but you don't have to extract (as opposed to decompress) them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top