![]() |
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 |
| can someone help me with modifying this file | eamani_sun | Shell Programming and Scripting | 2 | 05-22-2008 01:15 PM |
| Modifying a csv file from Shell Script | not4google | Shell Programming and Scripting | 2 | 11-21-2006 06:47 AM |
| Final Output | charbel | Shell Programming and Scripting | 4 | 06-29-2006 12:38 PM |
| Modifying the URL to point to another location in a .sh UNIX file | pjanakir | UNIX for Dummies Questions & Answers | 6 | 01-25-2006 03:19 PM |
| Modifying binary file by editing Hex values ? | Nicol | UNIX for Advanced & Expert Users | 4 | 11-04-2005 08:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Modifying the final output file
Hey all,
I am haivng n number of files all of them are of the same format but different details. i.e File1 is having the folloeing details: "Account1",123 "Account2",10 "Account3",12355 "Accountn",555 File2 is having the folloeing details: "Account1",1234 "Account2",100 "Account3",2290 "Accountn",679 and so on.....so as you can see i am having n number of files, all files have the same account number inside and the only difference is in the number of recrods each account has in each file.....Now what i want to do is to generate a final file which will have all the accounts mentioned earlier along with their records, it will be somehow i a table format.i.e.: Final output file should look like the following: "Account1",123,1234 "Account2",10,100 "Account3",12355,2290 "Accountn",555,679 Any idea on how to do this? |
|
||||
|
A variation of anbu23's script, which is what I think he was attempting (less syntax errors
)Code:
nawk -F"," '
BEGIN { FS=OFS="," }
{ arr[ $1 ] = (arr[ $1 ]) ? arr[ $1 ] FS $2 : $2 }
END { for (i in arr) print i, arr[i] }
' file_1 file_2 file_n
|
|
||||
|
Quote:
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|