![]() |
|
|
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 |
| Question about sort specific column and print other column at the same time ! | patrick87 | Shell Programming and Scripting | 3 | 10-07-2009 07:43 AM |
| How to pick values from column based on key values by usin AWK | repinementer | Shell Programming and Scripting | 16 | 07-24-2009 09:59 AM |
| how to read the column and print the values under that column | gemini106 | Shell Programming and Scripting | 6 | 03-28-2008 07:05 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 09:57 AM |
| replace a column values with the first value in column | sumeet | UNIX for Advanced & Expert Users | 3 | 02-06-2007 01:13 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I still consider myself to definitely be a beginner with awk but your question intrigued me so I worked at it a bit. The following doesn't meet 100% of your requirement but I just can't figure it out from this point. Code:
$ awk -F, '{split($3,a,"|"); n=asort(a,b); for (i=1; i<=n; i++) sort=sort "|" b[i]; print $1 "," $2 "," sort}' file
input Code:
TEST1,ABC,5|4|1|3|2 TEST2,DEF,10|7|25|11|52|19 TEST3,XYZ,5|11|52|1 output Code:
TEST1,ABC,|1|2|3|4|5 TEST2,DEF,|1|2|3|4|5|7|10|11|19|25|52 TEST3,XYZ,|1|2|3|4|5|7|10|11|19|25|52|1|5|11|52 As you can see the problem I'm having is getting the for loop to only include the parts of the array relevant to the current line. I'm scratching my head for now, but I know I'll figure it out soon
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|