![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a date as a first column | figaro | UNIX for Dummies Questions & Answers | 2 | 05-21-2008 02:00 PM |
| Help in adding positive & negative values in a column | berlin_germany | Shell Programming and Scripting | 4 | 02-09-2007 02:03 PM |
| Adding a column of numbers | Khoomfire | UNIX for Advanced & Expert Users | 1 | 01-18-2006 01:55 AM |
| adding a column at the end of the record | pavan_test | UNIX for Dummies Questions & Answers | 2 | 11-07-2005 08:39 AM |
| Changing the column for a row in a text file and adding another row | aYankeeFan | Shell Programming and Scripting | 9 | 05-02-2005 06:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
FILE:Adding new column
Is it possible to add a new column in a file by matching a key element in second file ?
File 1 2 a 3 b 4 d 5 g 6 j 7 m File 2 4 hjjjj 5 aaa 6 sasa 7 dsds 2 dsdf 3 fdsfg we need to add 2nd coulmn of first file as the new column in second file by matching the first columns in both files. (First Column is like a foreign key in the case of databases) Output File 4 hjjjj d 5 aaa g 6 sasa j 7 dsds m 2 dsdf a 3 fdsfg b Please help in this regard. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Sort the files:
Code:
sort file1.txt > file1.new.txt sort file2.txt > file2.new.txt Code:
join file2.new.txt file1.new.txt Code:
2 dsdf a 3 fdsfg b 4 hjjjj d 5 aaa g 6 sasa j 7 dsds m |
|
#3
|
|||
|
|||
|
Thank you so much Glenn...
Came to know about join from you |
|||
| Google The UNIX and Linux Forums |