I'm working on a script that serves to search a tar for strings and output files containing those strings to a folder- this is done so that I don't have to untar a big file and then search through that and then delete the unnecessary files
This is what I have so far:
#!/bin/bash
tarname=$1
pattern=$2
count=1
tar -tf $tarname | while read -r FILE
do
tar -xf $tarname $FILE
##grep the pattern with the file here...
done
So the problem I have with this is it assumes that the tar'd things from the tar file are all files, but they could just as easily be directories- is there a way to tar the files recursively with this code?
By the way, this is all in Unix, so some of the stuff might be outdated and may not have access to newer versions of commands