Register
It is currently Thu Oct 30, 2014 10:39 am

Limit ls -t to ten oldest files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Sun Apr 04, 2010 11:47 am   

Joined: Sun Apr 04, 2010 11:44 am
Posts: 9
Hi,

I'm looking for a script that limits the output of ls -t to show only the 10 oldest directories or files.
Can anyone help?? :-w


Top
 Profile  
 PostPosted: Sun Apr 04, 2010 6:04 pm   

Joined: Tue Mar 02, 2010 9:55 pm
Posts: 24
Location: Canada
If you try something like

Code:
ls -t | sort -R | head -n10


Top
 Profile  
 PostPosted: Tue Apr 06, 2010 5:48 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Code:
ls -rt | head


Top
 Profile  
 PostPosted: Thu Apr 08, 2010 2:49 pm   

Joined: Sun Apr 04, 2010 11:44 am
Posts: 9
Thanks peeps! Works perfectly!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP