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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do I go about finding a value located in one file in another?
# 1  
Old 11-13-2008
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

Last edited by mojoman; 11-13-2008 at 06:17 PM..
# 2  
Old 11-14-2008
Mohit,

read this...
man join

It might be as simple as:
join file1 file2 > resultfile
# 3  
Old 11-14-2008
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.

Code:
grep -wf file1 file2 > outputfile

The -w makes it match whole words so that it doesn't confuse MARK and MARKETA, for example.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sudo dmidecode where is the file located ?

Been through all my /sys /sbin /bin directories and can't seem to find it. (2 Replies)
Discussion started by: jcnewton13
2 Replies

2. Shell Programming and Scripting

Need help to change the content for remote located file

Hi All, I have a file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me it... (1 Reply)
Discussion started by: tmarjuna
1 Replies

3. UNIX for Advanced & Expert Users

Need help to change the content for remote located file

Hi All, I have one file that sits on 4 diffrent servers, those servers are diffrent region based and they are authentication protected and that file has a diff port numbers, so when run the script it must ask my login details,region of server and port no for that file once it took from me... (1 Reply)
Discussion started by: tmarjuna
1 Replies

4. Shell Programming and Scripting

Executing KSH batch file located in specific folder

Ok apologies if this is trivial or doesn't make sense but I am quite new to korn shells; So I have a .ksh batch file located in a folder of my choosing, I want to run this file in a korn shell. The problem though is that I want to get VBA code to do this. I have (VBA) code which opens command... (1 Reply)
Discussion started by: cjsewell
1 Replies

5. UNIX for Dummies Questions & Answers

how to know the device on which the file is located

Hi, i want to know on which device a file is located is there any command or anyway to know it thanks santosh (5 Replies)
Discussion started by: santosh149
5 Replies

6. Shell Programming and Scripting

use awk to read randomly located columns in an excel file

Hi, I have an excel file that have a random count of columns/fields and what im trying to do is to only retrieve all the rows under 2 specific field headers. I can use the usually command for awk which is awk 'print{ $1 $2}' > output.txt, but the location of the 2 specific field headers is... (9 Replies)
Discussion started by: mdap
9 Replies

7. Shell Programming and Scripting

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (2 Replies)
Discussion started by: SanketJOSHI
2 Replies

8. UNIX for Dummies Questions & Answers

Deleting a file located on another server

Hi, I have successfully copied a file from one server to another using following command. user1@server1# scp test.jsp user2@server2:/home/ Now i want to delete that copied file(test.jsp) from "server2" by running some command from server1. Please help... (1 Reply)
Discussion started by: SanketJOSHI
1 Replies

9. Shell Programming and Scripting

Pls Help - Need to edit file located in several directories

I need to update an entry called "mail.RiskNavigatorFromEmailAddress" in all of the "Application.properties" files below, which are located in several different directories... Each of these Application.properties files has the following entry: ... (3 Replies)
Discussion started by: kthatch
3 Replies

10. Solaris

Where Xorg X-Lock file is located in Solaris?

I am using Xorg server with Solaris 10. After unnormal poweroff dtlogin tells: "The X-server can not be started on display :0" I am absolutelly sure it is because there is still a X-lock file from the previouse X-session somewhere, but I do not know where is it located in Solaris! :confused: (2 Replies)
Discussion started by: eugrus
2 Replies
Login or Register to Ask a Question