S
S
Sergey Savostin2012-05-17 18:42:31
bash
Sergey Savostin, 2012-05-17 18:42:31

Help with the team

Task: Get a list of files with a specific string.
Everything would be fine, but the files are gziped.

Currently stopped here:

find . -type f -regex '\.txt\.gz$' -exec sh -c 'gunzip -c "$1" | grep "Find me"' {} {} \; 

But in the end I get only “Find me”, but I need a list of files.
How to get the filename that passed in grep?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
st0ne_c0ld, 2012-05-17
@savostin

Something like this?
find . -type f -name "*.txt.gz" -exec zgrep -H "Find me" {} \;

U
un1t, 2012-05-17
@un1t

 grep "hellow world" --with-filename --line-number `find . -name '*.html'`

V
vajadhava, 2012-05-17
@vajadhava

grep -rl 'search string' /path/where/search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question