Results 1 to 1 of 1
Hi,
I have a file:
979798707
787862348
766428634
I want to see if all the records in the file are present in the contents of the files of a particular ...
- 03-15-2011 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 12
tell if grep doesn't find a match
Hi,
I have a file:
979798707
787862348
766428634
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.
something like:
while read line
do
# 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)?
Thanks,Last edited by realtest; 03-15-2011 at 02:48 PM.


Reply With Quote