LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2012, 01:56 PM   #1
iconig
LQ Newbie
 
Registered: May 2012
Posts: 28

Rep: Reputation: Disabled
matching and printing specific lines


I have been trying to do this for sometime now but I have not been able to do it. Say I have a file named 'John', with content like this:
Code:
6
10
12
988
266
192
234
and I have other files with each file listed from 1- 50000 like this:
file A
Code:
1 0
2 1
3 0
4 0
5 0
6 0
7 0
8 0
9 1
10 0
.  1
.  0
.  1
50000  0
I have many of such files A but with different filenames. These are all in the same directory.
I want to use file named "john" to compare field 1 in file A and all the other files like this: wherever you have 6 in filed 1 file A print entire line, then take 10 from file John look for 10 in file A and print line. Output will look like this:
Code:
6 0
10 0
etc
This comparism is then done for each other file
Thanks all
 
Old 08-23-2012, 02:02 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
is this homework ? what have you tried so far ? where are you stuck ?

look into the -f and -w parameters of the grep command.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing $ Lines After Finding Specific Pattern pravin.bhande Programming 6 04-12-2012 11:20 AM
[SOLVED] awk with pipe delimited file (specific column matching and multiple pattern matching) lolmon Programming 4 08-31-2011 01:17 PM
Printing specific lines of a file using script. barunparichha Linux - Software 6 05-20-2009 01:31 AM
Sed command to print matching lines and 2 lines above.. DX398 Programming 12 10-01-2008 09:25 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 10:19 AM


All times are GMT -5. The time now is 04:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration