简体   繁体   中英

Bash : grep -i -vFf

I have 20 files. In each file I have a list of the occurring words and their frequency. example

5 hi
10 test
20 bye 
5 Hello

etc

And another file in which there is a list of words.

hi   
Hello 
goodbye

How can I use one grep -v on all of these ?
I tried

for i in  {1..20} ; 
do
grep -i -vFf ./../data/input/blacklist.txt ./../data/dico/$i.dico.forme.lemme.txt > ./../data/selection/$i.select.txt  ;
done

But it didn't work.
What I expect was to have

10 test
20 bye

what I get

5 hi
10 test
20 bye
5 Hello

So, I created the files according to your specification and dit the grep:

ljm[tmp]$ cat lemme
5 hi
10 test
20 bye 
5 Hello
ljm[tmp]$ cat blacklist
hi
Hello
ljm[tmp]$ grep -ivf blacklist lemme 
10 test
20 bye 

This means that it should work. Apparently, you are doing something different than you stated in your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM