![]() |
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 |
| need help in sort | ali560045 | Shell Programming and Scripting | 2 | 12-04-2007 07:38 AM |
| sort | prasathlogu | UNIX for Dummies Questions & Answers | 1 | 10-08-2007 06:56 AM |
| du -h | sort ? | fongthai | Shell Programming and Scripting | 6 | 11-02-2006 08:59 PM |
| How do i sort? | abhijeetkul | Shell Programming and Scripting | 1 | 12-22-2005 03:49 AM |
| 2nd sort key | whatisthis | UNIX for Dummies Questions & Answers | 1 | 10-20-2004 10:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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... |
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|