- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How can i order a file by date ..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 12:31 PM - last edited on тАО03-10-2013 11:04 PM by Cathy_xu
тАО02-22-2010 12:31 PM - last edited on тАО03-10-2013 11:04 PM by Cathy_xu
i have a file like this one (3500 rows apox):
user1 group1 Apr 12 2008 /home/user1.txt
user1 group3 May 18 2007 /home/user1.txt
user2 group5 Jan 23 2006 /home/user1.txt
user1 group1 Apr 12 2009 /home/user1.txt
user5 group6 Aug 17 2006 /home/user1.txt
user1 group3 Jul 16 2008 /home/user1.txt
user1 group8 Feb 15 14:13 /home/user1.txt
user5 group5 Jan 16 12:13 /home/user1.txt
user3 group1 Apr 15 2009 /home/user1.txt
user1 group8 Apr 13 2008 /home/user1.txt
......
......
......
......
......
i need to order these lines by date?
how can i do that?
do i have to make a program?
do you know something quick to do it?
thanks in advance.
P.S.This thread has been moved from HP-UX>System Administration to HP-UX > languages-HP Forums Moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 01:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 01:09 PM
тАО02-22-2010 01:09 PM
Re: How can i order a file by date ..
If you didn't have mixed timestamp information with HH:MM and YYYY, then you could simply sort your file like this:
# sort -k5n,5 -kM3,3 -k4n,4 file
Since file timestamps that are within 6-months of the current date are reported with the HH:MM in place of the YYYY, you need to do something to manufacture the correct YYYY value as a sort key and/or generate a sort key that is an epoch seconds in the first place, and sort that.
Regards!
...JRF...
- Tags:
- Sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 01:22 PM
тАО02-22-2010 01:22 PM
Re: How can i order a file by date ..
the month sort above appears to be incorrect. I believe it should read:
sort -k5n,5 -k3M,3 -k4n,4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 01:30 PM
тАО02-22-2010 01:30 PM
Re: How can i order a file by date ..
> OldSchool: the month sort above appears to be incorrect. I believe it should read: sort -k5n,5 -k3M,3 -k4n,4
Yes, I transposed the "M". Thanks.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2010 01:34 PM
тАО02-22-2010 01:34 PM
Re: How can i order a file by date ..
ls -rlt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2010 06:02 AM
тАО02-23-2010 06:02 AM
Re: How can i order a file by date ..
ls -rlt" -and-
"# ls -lr"
the problem is she's asking about the contents of a file, as indicated by ..."i have a file like this one (3500 rows apox)...:
given the existing contents, its pretty much a "sort" issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2010 06:16 AM
тАО02-23-2010 06:16 AM
Re: How can i order a file by date ..
and ls -lr
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2010 06:44 AM
тАО02-23-2010 06:44 AM
Re: How can i order a file by date ..
Did that posting contribute anything (other
than repeating an error)?
> i need to order these lines by date?
Even if the desire were to sort an "ls"
report, how would "-lr" use the date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2010 06:49 AM
тАО02-23-2010 06:49 AM
Re: How can i order a file by date ..
> Jupinder: sort -k5n,5 -k3M,3 -k4n,4
...which adds what given that this is what I posted *yesterday*?
...JRF...