The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need help listing/sorting files dave_angel Shell Programming and Scripting 2 11-23-2006 07:16 PM
How can i get directory listing? haisubbu UNIX for Dummies Questions & Answers 2 08-25-2006 09:03 AM
Full Directory Listing... B14speedfreak UNIX for Dummies Questions & Answers 5 05-11-2006 08:06 AM
Timestamp in directory listing vijashok UNIX for Dummies Questions & Answers 2 10-06-2005 10:03 AM
Recursive directory listing without listing files psingh UNIX for Dummies Questions & Answers 4 05-10-2002 10:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2007
Sepia Sepia is offline
Registered User
  
 

Join Date: Apr 2007
Location: England
Posts: 49
Sorting Directory Listing

If I do an ls -l on a directory I get this:
-rw-r--r-- 1 root other 5248094 Jun 24 03:56 monitor.log.7
-rw-r--r-- 1 root other 5248303 Jul 11 11:19 ct.log.1
-rw-r--r-- 1 root other 5248907 Jun 29 06:01 ct_monitor.log.5
-rw-r--r-- 1 root other 5249042 Jun 19 00:55 ct_monitor.log.9
-rw-r--r-- 1 root other 5376119 Jul 11 03:31 pLog.log

etc

If I want to sort if by date how would I go about it?

I Googled and found this:
sort -k1,1M -k2n
but when trying it it sorted it by size.

I don't really understand what sort -k1,1M -k2n refers to, when I changed it to sort -k2,2M -k3n. It did the same thing, I was thinking it might sort the next column.

Thanks.
  #2 (permalink)  
Old 07-11-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Use t option to get listing sorted by modification time and use r option to reverse the listing sorted by time
Code:
ls -lt
Code:
ls -ltr
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0