The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with using comm jathin12 Shell Programming and Scripting 4 02-27-2009 07:47 AM
Problem in using diff ragavhere Shell Programming and Scripting 6 04-19-2008 09:56 AM
getting problem in my code:::: plz help...(multithreaded appn with serial comm.) arunchaudhary19 High Level Programming 0 10-29-2007 09:38 AM
getting problem in my code:::: plz help...(multithreaded appn with serial comm.) arunchaudhary19 Linux 0 10-26-2007 06:24 AM
Diff command problem gvsreddy_539 Shell Programming and Scripting 4 09-30-2007 08:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-07-2009
InfoSeeker InfoSeeker is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 2
Post Not sure how to use diff and comm for my problem

Hello,
Apologies if this question has been repeated before, but I am getting myself confused even more as I scan the posts!

I have two files, file1 is a column:
1dlwa_
1s69a_
1idra_
1ngka_

And file2 has three columns (columns seperated by tabs):
1dlw a_ A
1uvy a_ A
1dly a_ A
1uvx a_ A
1s69 a_ A

I want to only extract from file2 those rows where the first & second column concatenated together matches the first column of file1. In this example above, I would only want to see:
1dlw a_ A
1s69 a_ A

And I want to save these in a new file, file3. How would I use diff, comm, or any combination of those to do it?
Thank you in advance for your help!
InfoSeeker
  #2 (permalink)  
Old 03-07-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Use nawk or /usr/xpg4/bin/awk on Solaris if you get errors:

Code:
awk 'NR==FNR{a[$0];next} $1$2 in a' file1 file2
Regards
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0