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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
struggling within awk geeko Shell Programming and Scripting 4 10-09-2007 03:14 AM
Help- Unix File Compare- Struggling guiguy UNIX for Advanced & Expert Users 2 01-06-2007 08:32 PM
Struggling with a text file pau Shell Programming and Scripting 13 05-03-2006 10:47 AM
Struggling with mkfifo alan UNIX for Dummies Questions & Answers 20 04-20-2004 10:10 PM
struggling with addusr ... Dufty UNIX for Dummies Questions & Answers 2 01-22-2002 05:00 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-22-2009
moldoverb moldoverb is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
Struggling with AWK

I know this is an easy problem, but I've been struggling with it all morning and finally admit I need help.

I have two files that I need to compare. After doing this the easy way (grep -F) I realize that there are other fields in file2 that match field1 in file1, so I turned to awk.

I want to compare the first field in each, and if field1 of file1 matches field1 of file2, print out the entire line in file2. I've been trying to write an awk script but just don't fully understand how to do this.

I get as far as:

Code:
awk '
FS="\t";
BEGIN {
while (getline <"file1.txt"){
$fieldq==$1;
and I can't figure out how to read in the second file to do the comparison and then print $0 from file2.

Last edited by Franklin52; 10-22-2009 at 11:04 AM.. Reason: Please use code tags!
 

Bookmarks

Tags
awk

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 02:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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