![]() |
|
|
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 |
| how to use sed to sort out this question | sonicstage | Shell Programming and Scripting | 2 | 04-07-2008 04:39 AM |
| SORT question | ssgatbliss | UNIX for Dummies Questions & Answers | 2 | 03-22-2007 01:15 PM |
| Sort/Grep Question | aarondesk | UNIX for Dummies Questions & Answers | 5 | 03-06-2006 05:57 PM |
| Sort Question | bobo | UNIX for Dummies Questions & Answers | 7 | 02-24-2006 12:04 PM |
| Using Sort | kemobyte | Shell Programming and Scripting | 1 | 11-30-2005 08:25 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
sort / cut question
Hi All,
I have a small problem, hope you can help me out here. I have a file that contains the same format of lines in 99% of the cases. 906516 XYZ.NNN V 0000 20070711164648 userID1 userID2 hostname 20070711164641 There are unfortunately several lines with these format: 906516 XYZ V 0000 20070711164647 userID1 userID2 hostname 20070711164641 The difference is in the 2nd coloumn. Sometimes its length is 3 , sometimes 7 digits long. Thus the number of delimiters between 2nd and 3rd column are also varied. Imagine the two lines as "V" in coloumn 3 would be in the same line... My scenario is: cut out the 1st(the number) and 5th (timestamp) coloumn and sort the result in reverse order using the timestamp column as key. My command is: cat filename |cut -f 1,15 -d " " |sort -r -k 2,2 Obviously this cannot work properly because sometimes the 5th column does not start at the 15th " " delimiter due the above mentioned reasons. Could you guys let me know a solution I can carry out this scenario? I checked man for cut but could not find an option of using sophisticated delimiters, etc... Thanks a lot! BearCheese |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|