Reputation: 826
In my script i am using the following...
edi824Files=`find $EDI_824_FILE_DIR -name "*$ediFileDate*.edi" -a "(" -mtime -1 ")"`
here $ediFileDate should be the current date, and $EDI_824_FILE_DIR has the value like DIR/. e.g: DIR/2014-01-24
the above one is working fine, but it just pull all the files with .edi extensions. But i would like to get only the files with a specific entry. for e.g: the files which containing the value "824". how can i achieve this?
Upvotes: 1
Views: 61
Reputation: 515
Try this:
find $EDI_824_FILE_DIR -name "*$ediFileDate*.edi" -a "(" -mtime -1 ")" -exec grep -l "824" {} \;
Upvotes: 2
Reputation: 108259
Pipe find through xargs and grep:
find ... | xargs grep '824'
This will list all the lines that contain "824", along with the filename and line number. If you just want the filenames, then:
find ... | xargs grep -l '824'
xargs reads from stdin. For each line read, it executes the command, passing the line as the last argument to the command.
Upvotes: 1