![]() |
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 |
| Remove lines, Sorted with Time based columns using AWK & SORT | karthikn7974 | Shell Programming and Scripting | 1 | 05-09-2008 11:04 PM |
| sort columns by field | kamel.seg | Shell Programming and Scripting | 4 | 02-20-2008 06:50 AM |
| add columns from file to another and sort | kamel.seg | Shell Programming and Scripting | 12 | 12-12-2007 02:39 PM |
| Help needed to sort multiple columns in one file | ahjiefreak | UNIX for Dummies Questions & Answers | 1 | 12-07-2007 05:50 AM |
| Sort by Columns | murbina | UNIX for Dummies Questions & Answers | 1 | 05-10-2004 02:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sort data in different columns
Hello all:
i have list with the following format Id Name Iid Value 0x4440001 customerCode 44077 0x11d2a PrimaryAddress 57.217.41.201 0x129fa Model_Handle 0x11322800 0x4440000 usid fi00bxtaa4 0x4440008 customerName Zurich while i needed to be in the next format customerCode PrimaryAddress Model_Handle usid 44077 55.217.41.201 0x11322800 fi00bxtaa4 how to do so ? regards |
|
||||
|
Quote:
but the input data will be repeated in the file in that way Id Name Iid Value 0x4440001 customerCode 44077 0x11d2a PrimaryAddress 57.217.41.201 0x129fa Model_Handle 0x11322800 0x4440000 usid fi00bxtaa4 0x4440008 customerName Zurich Id Name Iid Value 0x4440001 customerCode 44044 0x11d2a PrimaryAddress 57.210.40.20 0x129fa Model_Handle 0x11326500 0x4440000 usid fi00bxtbb0 0x4440008 customerName Zurich and so on ... |
|
|||||
|
I'm not sure if you want to sort or to change the format only:
(use nawk or /usr/xpg4/bin/awk on Solaris) Code:
awk 'BEGIN {
print "customerCode PrimaryAddress Model_Handle usid"
}
c && c < 5 {
v = v ? v FS $NF : $NF
}
++c == 6 {
print v
v = c = ""
}' filename
|
|
||||
|
Quote:
getting the same error awk: syntax error near line 4 awk: bailing out near line 4 |
|
||||
|
Quote:
when run script getting error awk: syntax error near line 1 awk: bailing out near line 1 please advice |
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl, unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|