Hi,
i'm new here (and to scripting too).
I was hoping for some help in comparing two files.
i have a file called 'file1' with a list of names in the following format:
adam jones
paul higgins
kelly lowe
i also have another file which may contain some of the names but with a lot of other stuff, this is called 'file2'. it contains info such as:
aaa aaaa paul higgins aaaaa
aaaaa aaaaa aaaa aa aa aaa
aaaa aaaa kelly lowe aaaaa
asdsaad adsadsa asdas
assadasd
sa etc
(where aaaa is just random stuff html)
i want to find the common names in both files and produce an output in the form of:
0
1
1
this is with reference to the 'master' file (file1). ie. it has found in the 'file2' file that there are no adam jones, and 1 each of paul and kelly.
to do this task, i am using the following shell script however it does not seem to work:
#!/bin/sh
for i in file1
do
grep -c $i file2
done
it seems like quite a simple script, but i'm not sure why it does not work?(it only seems to grep for the first name, but does not loop through)
thanks for any help