Hi,
I need small help from you people.
In a directory there are around 150 odd files and few them contain the word "TRACK" and few are not.
How can I find out the the list of those files which doesn't contain the word "TRACK"?
Thanks,
Siba
Hi,
I need small help from you people.
In a directory there are around 150 odd files and few them contain the word "TRACK" and few are not.
How can I find out the the list of those files which doesn't contain the word "TRACK"?
Thanks,
Siba
grep -vl TRACK *
If it contains subdirectories, you might want to add a -R.
Hi zaxxon,
No, It's not giving the expected result. It gives me all the files in that directory.
I think it should Because when we issue command
grap -v "TRACK" *
It gives the line which doesn't contain the word "TRACK" so
grep -vl "TRACK" *
would also gives all the file names because only few lines in file contains the word "TRACK". But I need to discard those file which contain the word "TRACK". grep with -vl option is not working.
Though I am using one script for this purpose. The script is like
for fname in `ls *sh`
do
#echo $fname
`grep -q "TRACK" $fname`
if [ $? == 1 ];then
echo "$fname"
fi
done
ls >tmplist ; grep -l TRACK * | grep -vf - tmplist
ls | while read a ; do ( ! grep -l TRACK $a >/dev/null ) && echo $a ;done
You're right - my answer was wrong, sorry.