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
compare columns from seven files and print the output smriti_shridhar Shell Programming and Scripting 7 06-11-2008 12:22 AM
awk to compare lines of two files and print output on screen chlfc Shell Programming and Scripting 3 03-24-2008 04:16 AM
Trying to compare lines in 2 files brdholman Shell Programming and Scripting 2 09-20-2007 07:46 AM
Compare two files and merge columns in a third CM64 Shell Programming and Scripting 20 04-04-2007 01:41 PM
Compare multiple columns between 2 files stevesmith Shell Programming and Scripting 15 09-20-2006 12:04 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 12-04-2003
giviut giviut is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 5
compare files by lines and columns

Dear All,

Is it possible to compare 2 files line to line using column values?

for example I have file1:

1;givi;01012000;wer
2;sss;02012000;rrr
3;ccc;03012000;ttt

file 2:

0;uuu;01012000;lll
1;givi;01012000;wer
2;sss;02012000;rrr
3;ccc;03012000;ttt
5;givi;01012000;hhh

I want to get only lines from file2 where combination of 2nd and 3rd columns do not exist in file 1. it means that one line from file2 shuld compare to all lines in file1?????

Thanks in advance.

Givi
  #2 (permalink)  
Old 12-04-2003
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,408
Try...
Code:
awk -F';' 'BEGIN{while(getline<"file1") a[$2,$3]=1};a[$2,$3]!=1' file2
  #3 (permalink)  
Old 12-04-2003
giviut giviut is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 5
Thank you very much.
Exactly I wanted.
  #4 (permalink)  
Old 01-16-2008
pp56825 pp56825 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 32
help needed

Hello all awk masters.

i have query but i need add some change and i don't know how.
my current awk program is :

nawk -F"~" -f m.awk file1

m.awk:
BEGIN {
while(getline<"file2")
arr[$1,$7]=1
}
arr[$1,$7]!=1 {print }

additionaly i need to change $2 from file1 to $2 from file2
so display is line from file1 with $2 from file2

Thanks in advance.
Peter
  #5 (permalink)  
Old 01-17-2008
phamp008 phamp008 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 36
Hello Ygor,

Would you please explain what that does

a[$2,$3]=1};a[$2,$3]!=1' from your previous post. I am trying to digest this code.
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 07:17 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