LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-06-2013, 05:45 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
List all regular files in the disk sorted by modification time.


Hi: Let be the set of all regular files on my linux partition. I'd like
to list its elements in chronological order, with respect to modification
time. Any simple way to do it?
 
Old 11-06-2013, 05:52 AM   #2
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
Code:
find /path -xdev -type f -printf "%Ts %p\n" | sort -n | awk '{print $2}'
will sort from old to new, if you want recently modified files first, add the "-r" argument to the sort command, or pipe the result to `tac`.
 
2 members found this post helpful.
Old 11-06-2013, 06:48 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks for your reply. But tell me, how could I have the same list, but with a second column displaying the modification date?
 
Old 11-06-2013, 07:26 AM   #4
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
Technically, you could just remove the "| awk '{print $2}'", then it would print the "unix-time" (seconds since midnight at 1st Jan 1970). But I'm guessing you want something human readable. This should work
Code:
find ~/tmp -type f -printf "%TY-%Tm-%Td %TH:%TM:%TS %p\n" | sort
by printing "YYYY-MM-DD HH:MM:SS.... /path/to/file" so a lexicographical ordering happens to also be chronological.
You can change the time format to your liking (see `man 3 strftime`), but be careful with non-numerical time variables (eg. "03:16 AM" < "03:16 PM", but "Friday" < "Monday").
 
1 members found this post helpful.
Old 11-06-2013, 08:43 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Terrific! Thanks a lot.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] listing files recursively, sorted by time, limited head Harju Linux - Newbie 12 03-25-2011 10:51 AM
[SOLVED] looking for a way to list files sorted by size mark_alfred Linux - General 4 08-22-2009 09:20 AM
Shell script to build a list of karaoke music files sorted by artist and title! imix40 Linux - Newbie 4 08-13-2008 07:10 PM
List/compare a directory's files' creation and modification dates LittleTrish Linux - Newbie 3 10-22-2007 02:38 PM
How do I produce sorted list of files in current directory over a certain size? bangback Linux - Newbie 3 10-25-2006 12:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration