Results 1 to 4 of 4
Hello there,
I'm relatively new to Unix, and I would like to know the commands/script for searching within files inside a tarball(.tar file).
Let's say I have a file ABC.tar, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-25-2012 #1Just Joined!
- Join Date
- Jul 2012
- Posts
- 2
Searching within files in a tarball archive (.tar)
Hello there,
I'm relatively new to Unix, and I would like to know the commands/script for searching within files inside a tarball(.tar file).
Let's say I have a file ABC.tar, that contains many files such as X.txt, Y.txt, Z.txt.. One of these files (X,Y,Z..) contains a string 'Hello'. How can i grep within the .tar file to find which file contains the string 'Hello', without extracting the .tar?
Thanks.
- 07-26-2012 #2Just Joined!
- Join Date
- Jul 2012
- Posts
- 10
Code:F=`tar --list -x ABC.tar` for Z in $F; do if tar -xOf ABC.tar $Z | grep Hello ; then echo found in $Z fi done
- 07-26-2012 #3
This works for me:
Code:tar -O --wildcards -xf ABC.tar | grep -I -r -i 'Hello' ./
- 07-27-2012 #4


Reply With Quote

