Usage of grep correctly

Viewed 41

I have 180 sub directories under main directory. I need to grep "Unresponse" in add_report.rpt file in all 180 sub-directories like below:

tile#t/PA#_output/add_report.rpt

where # represents tile1_t, tile2_t ...... tile180_t(because I am unable to use *)

I tried with this in the current directory:

grep -r "Unresponse"

But I am also getting from other sub-directories as well under tile#

Can anyone please help me with the correct way to grep. I only need the output from this path :

tile#_t/PA_#_output/add_report.rpt
1 Answers

You can use the * glob pattern to match any string. This is a bash feature and has nothing to do with grep:

grep 'Unresponse' tile*_t/PA_*_output/add_report.rpt
Related