
find -name [FILE_PATTERN] -print0 | xargs -0 zgrep "[TEXT_TO_FIND]"Where:
[FILE_PATTERN] : is the pattern of the files.
[TEXT_TO_FIND] : is the text to find inside the files.
Let's say we have the following files:
peter-01.gz
peter-02
peter-03.gz
peterA
peterB.gz
maria-01
maria-02.gz
And you want to find the text "my friend" only in the files that begininng with "peter-". To do this, you can use the following:
find -name peter-\* -print0 | xargs -0 zgrep "my friend"
Note the use of \* as a wildcard.
0 comments:
Post a Comment