![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| selecting only few lines from many based on a common pattern | damansingh | Shell Programming and Scripting | 2 | 05-28-2008 06:29 AM |
| Common uses for Unix | rcengland | UNIX for Dummies Questions & Answers | 4 | 04-11-2008 06:37 AM |
| Merge files based on key | sbasetty | Shell Programming and Scripting | 3 | 02-02-2007 06:05 PM |
| is this a common problem in X? | 3bumbs plumming | UNIX for Dummies Questions & Answers | 3 | 12-06-2003 07:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Code:
>cat x.txt z 11 az x 12 ax y 13 ay >cat y.txt ay TT ax NN Code:
>sort x.txt > sx.tmp && sort y.txt > sy.tmp && join -1 3 -2 1 -o "1.1 1.2 1.3 2.2" sx.tmp sy.tmp | sort -r && rm -fr *.tmp y 13 ay TT x 12 ax NN .Aaron |
|
||||
|
Quote:
With awk: Code:
awk 'NR==FNR{a[$1]=$2;next}$3 in a{print $0 a[$1]" "a[$3]}' y.txt x.txt
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|