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 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-10-2008 09:22 PM
Compare 2 files and output result in pop up window hongsh UNIX for Dummies Questions & Answers 2 05-23-2008 06:50 AM
Compare 2 files and give uniq output rauphelhunter Shell Programming and Scripting 1 05-12-2008 01:47 PM
Compare 2 files for a single column and output differences samit_9999 UNIX for Dummies Questions & Answers 1 04-23-2008 09:02 AM
compare 2 files, output dups to file blt123 UNIX for Dummies Questions & Answers 2 07-15-2004 07:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 32
compare two col from 2 files, and output uniq from file 1

Hi,
I can't find how to achive such thing, please help.
I have try with uniq and comm but those command can't compare columns just whole lines,
I think awk will be the best but awk is magic for me as of now.

file a
a1~a2~a3~a4~a6~a7~a8

file b
b1~b2~b3~b4~b6~b7~b8

output 1:
compare columns 3 from files a and b
print all lines from file a where where column a3 is present in file b as b3
a1~a2~a3~a4~a6~a7~a8

Regards
Peter
Reply With Quote
Forum Sponsor
  #2  
Old 01-10-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,200
awk '{print $3}' file.name > new.file.name
then the same for the second file, but append the result, and then "uniq -d" which will print only the duplicates.
Reply With Quote
  #3  
Old 01-10-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,907
Do you want this?

Code:
awk 'NR==FNR{x[$3];next}$3 in x' FS="~" fileB fileA
Use nawk or /usr/xpg4/bin/awk on Solaris.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0