Reputation: 2140
I am trying to retrieve only the file names in a zip folder where those files contain a specific string (the string inside the file, not part of the file name). I tried the following command:
unzip -l results.zip | zipgrep -lir "Token" *
but it does not retrieve any results. It just starts a new command line. Is this the right way to just get the filenames that contain the string Token
?
Upvotes: 1
Views: 1601
Reputation: 31895
zipgrep -l "Token" results.zip
does the work
It returns
results/filexxx.txt
if fielxxx.txt contains Token
If you just want to get the filename without folder results
:
zipgrep "Token" results.zip | awk -F: '{print $1}' | awk -F'/' '{print $2}'
Upvotes: 0
Reputation: 785108
You don't need to call unzip
if you're using zipgrep
. Just use zipgrep
directly on a zip
file like this:
zipgrep -li "Token" results.zip
Note that there is no need to use -r
(recursive) option here.
Upvotes: 1