The UNIX and Linux Forums  

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
Awking!! Printing decimal output is struck divzz Shell Programming and Scripting 4 05-28-2008 09:02 AM
Splitting huge XML Files into fixsized wellformed parts Malapha Shell Programming and Scripting 0 03-17-2008 11:35 AM
grepping many values from same files Sreejith_VK Shell Programming and Scripting 2 03-15-2008 08:41 AM
grepping lines out of files mariner UNIX for Advanced & Expert Users 2 09-24-2004 09:12 AM
diff 2 files; output diff's to 3rd file blt123 Shell Programming and Scripting 2 05-28-2002 12:29 PM

Closed Thread
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
  #1 (permalink)  
Old 07-17-2008
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,125
you didn't mention the FieldSeparator in your original post - it was assumed to be 'space||tab'.

Code:
BEGIN {
   FS=OFS=","
}
{ idx = $1 SUBSEP $2 SUBSEP $5 SUBSEP $6 }
NR==FNR { fnew[ idx ] = $0; next }
{
   if ( !(idx in fnew) )
      $0 = $0 ORS fold[idx]
}
1
  #2 (permalink)  
Old 07-17-2008
jeffpas jeffpas is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 60
I did put that in:

BEGIN{FS=OFS=","}
{ idx = $1 SUBSEP $2 SUBSEP $5 SUBSEP $6 }
NR==FNR { fnew[ idx ] = $0; next }
{
if ( !(idx in fnew) )
$0 = $0 ORS fold[idx]
}
1


Not sure ??? I don't know why but I am getting both lines of file2.
Did this happen with you?
It sure looks like it should work.
very odd.
  #3 (permalink)  
Old 07-17-2008
jeffpas jeffpas is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 60
i'm beat
  #4 (permalink)  
Old 07-17-2008
jeffpas jeffpas is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 60
I've got a way:

----------

#!/bin/ksh

file1="file1"
file2="file2"

nawk -F, 'BEGIN {
while ((getline < "'$file1'") > 0) {
file2_ar[$1] = $1;
file2_ar[$2] = $2;
file2_ar[$5] = $5;
file2_ar[$6] = $6;
}
OFS=","; }

{
if (file2_ar[$1] && file2_ar[$2] && file2_ar[$5] && file2_ar[$6]);
else
print $0;
}
END{}' $file2 > OUT


-----------

The other way wouldn't seem to work for me, it looked alot cleaner, but hey. Temp Man lives another day!.......thanks 4 help
  #5 (permalink)  
Old 07-17-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
Timtowtdi

Code:
nawk -F, '{
   if (NR == FNR)
      print ar[$1$2$5$6] $0
   else
      if (!($1$2$5$6 in ar))
         print
}' file1 file2
Closed Thread

Bookmarks

Tags
awk, grep

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 12:03 PM.


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