I have a file named data_file with data: london paris newyork italy...50 more items
Have a directory with over 75 files, say dfile1, dfie2...afle75 in which i am perform
You could use grep's q
option to stop searching after the first match and f
option to obtain the patterns from a file:
for f in $(find . -type f); do
if $(grep -qf data_file "$f"); then
...
fi
done
If data_file
contains:
xxx
yyy
zzz
then grep -qf "$data_file" "$f"
evaluates to true if either xxx
, yyy
, or zzz
are found in $f
.