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
sql,multiple join,outer join issue robbiezr High Level Programming 0 06-06-2009 12:26 AM
awk, join or sed jkl_jkl Shell Programming and Scripting 1 04-15-2008 06:55 AM
Join jazz8146 UNIX for Dummies Questions & Answers 5 01-29-2008 11:42 AM
join (pls help on join command) summer_cherry Shell Programming and Scripting 1 12-31-2007 05:19 AM

 
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 09-30-2009
repinementer repinementer is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 158
awk for join

Is it possible to do this with awk command??

sort1.txt
Code:
a    10
b    20
sort2.txt
Code:
a
b
c
d
join command

Code:
join sort1.txt sort2.txt && join -v1 sort2.txt sort1.txt
output
Code:
a    10
b    20
c
d
Thanx

---------- Post updated at 05:44 PM ---------- Previous update was at 05:35 PM ----------

I come up with this. working fine but still has some join command in it

Code:
gispc290 ~/Desktop
$ awk 'NR==FNR{_[$1]=$1;next}$1 in _{print _[$1],$2,$3}' sort2.txt sort1.txt && join -v1 sort2.txt sort1.txt


---------- Post updated at 05:58 PM ---------- Previous update was at 05:44 PM ----------

May be this
Code:
gispc290 ~/Desktop
$ awk 'NR==FNR{_[$1]=$1;next}$1 in _{print _[$1],$2,$3}' sort2.txt sort1.txt && awk 'FNR==NR{a[$1]++;next}!a[$1] {print $0}' sort1.txt sort2.txt
 

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 03:07 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