![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help in sort | ali560045 | Shell Programming and Scripting | 2 | 12-04-2007 03:38 AM |
| sort | prasathlogu | UNIX for Dummies Questions & Answers | 1 | 10-08-2007 03:56 AM |
| du -h | sort ? | fongthai | Shell Programming and Scripting | 6 | 11-02-2006 04:59 PM |
| How do i sort? | abhijeetkul | Shell Programming and Scripting | 1 | 12-21-2005 11:49 PM |
| 2nd sort key | whatisthis | UNIX for Dummies Questions & Answers | 1 | 10-20-2004 07:46 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
sort help
Before
2007-04-29 01:02:02.440 2007-04-28 01:02:02.446 2007-04-29 01:02:15.113 2007-05-29 01:02:15.113 2007-04-28 09:09:04.939 2007-04-29 09:09:04.952 2007-05-29 09:09:05.886 2007-04-29 09:09:05.887 2007-04-28 09:00:49.066 After 2007-04-28 01:02:02.446 2007-04-28 09:00:49.066 2007-04-28 09:09:04.939 2007-04-29 01:02:15.113 2007-04-29 09:09:03.965 2007-04-29 09:09:04.952 2007-05-29 01:02:15.113 2007-05-29 09:09:05.886 How do i sort this in ascending order of year month date and for each date the timestamps should be in ascending order... |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
tr -s ':' ' ' < filename | tr -s '-' ' ' | sort | \
awk '{ printf("%s-%s-%s %s:%s:%s\n", $1, $2, $3, $4, $5, $6) }'
Code:
2007-04-28 01:02:02.446 2007-04-28 09:00:49.066 2007-04-28 09:09:04.939 2007-04-29 01:02:02.440 2007-04-29 01:02:15.113 2007-04-29 09:09:04.952 2007-04-29 09:09:05.887 2007-05-29 01:02:15.113 2007-05-29 09:09:05.886 |
|
|||
|
thx
Before
qa,2007-04-29 01:02:02.440 df,2007-04-28 01:02:02.446 gf,2007-04-29 01:02:15.113 df,2007-05-29 01:02:15.113 jh,2007-04-28 09:09:04.939 lk,2007-04-29 09:09:04.952 uj,2007-05-29 09:09:05.886 ki,2007-04-29 09:09:05.887 gy,2007-04-28 09:00:49.066 After df,2007-04-28 01:02:02.446 gy,2007-04-28 09:00:49.066 jh,2007-04-28 09:09:04.939 qa,2007-04-29 01:02:02.440 gf,2007-04-29 01:02:15.113 lk,2007-04-29 09:09:04.952 ki,2007-04-29 09:09:05.887 df,2007-05-29 01:02:15.113 uj,2007-05-29 09:09:05.886 If the data is in the above format how can we sort? |
|
||||
|
Hi, unics.
You've seen two solutions to a similar problem. How would you go about analyzing this problem after consulting man pages? What commands and options would you use? Show us some of your attempts and work ... cheers, drl |