Greg Freemyer wrote:
All,
I know "grep -F -f pattern_file <files-to-search>
will give me a list of all lines with a pattern in them.
I want to know which of the patterns had no matches.
I tried "grep -F --count -f pattern_file <files-to-search>" but it gives a cumulative count for all patterns
I want a count per pattern so I can find the patterns with 0 count.
Do I have to write a bash loop and call grep once for each pattern?
Yes, but to save execution time, count matches on the results, not the files to search: grep -F -f pattern_file <files-to-search> > $FOUND for PATTERN in `cat pattern_file` do COUNT=`grep -F $PATTERN -c` case $COUNT in 0 ) echo *** NO MATCHES: $PATTERN ;; * ) echo $COUNT:^I $PATTERN ;; esac done
Thanks Greg -- Greg Freemyer
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org