How do I go about finding a value located in one file in another?

Hi,

I have to determine which VALID users made a failed loggon attempts on our server.To make a long story short, I have isolated the list of all the usernames and number of attempts in one file, and have isolated the valid users who have made failed loggon attempts in another file. I now have to tell my script to match the valid users who have made failed loggon attempts to the entries that contain ALL users who made failed failed loggon attempts and the number of attempts. I was thinking of reading the file with valid users, reading line by line and grepping the username in the file that contains the failed usernames with number of attempts. I am new to shell scropting so I am not sure how to code this. Could someone provide an example please or suggest a better way to do what I want?

So if I have MARK in file 1 I need to match it with MARK 2 in file 2 and then output MARK 2 to another file. 2 being the # of failed loggon attempt.

Thanks,

Thanks,

Mohit

Mohit,

read this...
man join

It might be as simple as:
join file1 file2 > resultfile

Most greps accept a -f option to specify a file containing the list of strings to search for, so you can use that to filter the required lines out of file2, e.g.

grep -wf file1 file2 > outputfile

The -w makes it match whole words so that it doesn't confuse MARK and MARKETA, for example.