Results 1 to 1 of 1
Thread: report if record doesn't exist
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Sep 2010
tell if grep doesn't find a match
I have a file:
I want to see if all the records in the file are present in the contents of the files of a particular directory.
Basically I want to say if grep doesn't return anything, then report.
For example in /tmp dir I have 4 files and flast 2 values (787862348 and 766428634) are present in the files of /tmp dir, but first one (979798707) is not. I want to echo that in a reporting file.
while read line
# if ! grep -rl $line /tmp
echo $line >> are_not_present
done < "myFile"
How do I achieve " if ! grep -rl $line /tmp"? That is, if the line is found by grep, then grep will print the output, but if grep does'nt find it, it will print nothing. How can I check if grep didn't find it (i.e. printed nothing)?
Last edited by realtest; 03-15-2011 at 02:48 PM.