Search code examples
bashshelluniq

Bash : uniq -v && uniq -i


I'm using uniq -i to extract some terms from a file. But there is something wrong

I have 2 files for ex in the first one I have these 4 words

France
Construire 
TAO
construire 

In the second file I have only these 2 words

Construire 
TAO

So I used this command

$ cat 1stfile.txt | grep -i 2ndfile.txt 

And I have nothing as result. Can anyone explain to me why ? And also I want to know how to make it search for a word even if it is capitalize or not

I also tried the grep -v and what I have as result

Construire 
TAO 

which is weird

Thank you


Solution

  • grep can work over standard input or file depending on arguments and options, Maybe what you want:

    grep -f 2ndfile.txt -i 1stfile.txt
    
    • -f file obtain PATTERN from FILE
    • -i ignore case distinctions

    man grep or grep --help for more details.