Friday, November 28, 2014

linux - Search through tar files for a pattern and print the full path of what's found

I have directory tree with many tar files. Each tar file contains many other files. I want to search through all the tar files for a given pattern, and print the full path of any files within a tar that are found.


I got this far:
find . -type f -name '*.tar' -exec tar tf {} \; | egrep ''


Now my problem is that the above command only prints the name of the file within the tar that it finds. Ie, the output of the above is:
pattern.jpg
foundMe.txt


I would like the output to contain also the full path and the tar name where the file was found. How would I do this?


Thank you!

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...