Search words in multiple file line by line

Hi All

I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name.

Please show a representative sample of input, desired output, attempts at a solution and specify what OS and versions are being used.

2 Likes

Thanks for reply,

file child.txt has some 100+ server name written line by line.

like

SERVERWXM1
SERVERQWE2
SERVERUYT3 ..and so on 

And the Master file has all the servers name information more than 300 servers names.So I need to check SERVERWXM1 in the master file and so for 100+ server names ,if these server names is matching with master_files.txt then print yes or else not,both files have line by line entry.

You still didn't post clearly, with some guess try something like this

awk 'FNR==NR{A[$0];next}{print $0, ($0 in A ? "Yes": "No" )}' master_files.txt child.txt 

Print the matching (common) lines:

fgrep -xf master_files.txt child.txt

Print the non-matching lines (only in child.txt):

fgrep -vxf master_files.txt child.txt

If the files are sorted you can do the same with

comm -12 master_files.txt child.txt

and

comm -13 master_files.txt child.txt