![]() |
|
|
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 |
|
|
|
||||
|
Quote:
Code:
awk -F, '{sort=""} {split($3,a,"|"); n=asort(a,b); for (i=1; i<=n; i++) sort=sort "|" b[i]; print $1 "," $2 "," sort}' urfile
TEST1,ABC,|1|2|3|4|5
TEST2,DEF,|7|10|11|19|25|52
TEST3,XYZ,|1|5|11|52
Below is the code, which I try to make it shorter Code:
$ awk -F, '{printf "\n"$1","$2","} {split($3,a,"|"); n=asort(a); for (i=1;i<=n;i++) printf "|"a[i]} ' urfile
TEST1,ABC,|1|2|3|4|5
TEST2,DEF,|7|10|11|19|25|52
TEST3,XYZ,|1|5|11|52
Last edited by rdcwayx; 3 Weeks Ago at 11:26 PM.. |
| Bits Awarded / Charged to rdcwayx for this Post | |||
| Date | User | Comment | Amount |
| 3 Weeks Ago | mkastin | Thanks! | 1,000 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|