Quantcast
Channel: Active questions tagged bash+awk - Ask Ubuntu
Viewing all articles
Browse latest Browse all 102

Get Non matching string from file1 to file2

$
0
0

I have two files - file1 & file2.

file1 contains (only words):

ABC 
YUI 
GHJ 
I8O

file2 contains many paragraphs:

dfghjo ABC kll 
njjgg bla bla GHJ 
njhjckhv chasjvackvh .. 
ihbjhi hbhibb jh jbiibi 

I am using the command below to get the matching lines which contains word from file1 in file2:

grep -Ff file1 file2 

(Gives output of lines where words of file1 found in file2)

I also need the words from file1 which are not found in file2.

Can anyone help in getting this output:

YUI 
I8O

I am looking for a one liner command (via grep, awk, sed), as I am using pssh command and can't use while or for loops.


Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>