I'm searching a file which should not have this string "section" using shell/perl.
Please help me to find way grep -vl
command returns a file names if strings exists.
I'm searching a file which should not have this string "section" using shell/perl.
Please help me to find way grep -vl
command returns a file names if strings exists.
You may try like this:-
grep -Fxq "$MYFILENAME" file.txt
or may be like this:-
if grep -q SearchString "$File"; then
Do Some Actions
fi
In perl:
open(FILE,"<your file>");
if (grep{/<your keyword>/} <FILE>){
print "found\n";
}else{
print "word not found\n";
}
close FILE;
A lot of times I'll do it this way:
for f in <your_files>; do grep -q "section" $f && echo $f || continue; done
That should print out a list of files that contain the word "section" in them.