find $HOME -type f -print0 | perl -0 -wn -e '@f=<>; foreach $file (@f){ (@el)=(stat($file)); push @el, $file; push @files,[ @el ];} @o=sort{$a->[9]<=>$b->[9]} @files; for $i (0..$#o){print scalar localtime($o[$i][9]), "\t$o[$i][-1]\n";}'|tail Mon Sep 21 19:24:47 2009 /Users/andrew/Library/Logs/Sync/mobilemesyncstats.plist Mon Sep 21 19:24:47 2009 /Users/andrew/Library/Preferences/ByHost/com.apple.DotMacSync.0019e366823e.plist Mon Sep 21 19:24:48 2009 /Users/andrew/Library/Preferences/ByHost/com.apple.AOSNotification.0019e366823e.plist Mon Sep 21 19:24:54 2009 /Users/andrew/Library/Cookies/Cookies.plist Mon Sep 21 19:25:03 2009 /Users/andrew/Library/Preferences/com.apple.Terminal.plist Mon Sep 21 19:26:44 2009 /Users/andrew/Library/Mail/IMAP-andrew@x-fifteen.com@mail.x-fifteen.com/Sent Messages.imapmbox/Messages/311191.emlx Mon Sep 21 19:26:47 2009 /Users/andrew/Library/Logs/Sync/syncservices.log Mon Sep 21 19:26:55 2009 /Users/andrew/Library/Preferences/com.apple.mail.plist Mon Sep 21 19:27:48 2009 /Users/andrew/Library/Mail/IMAP-andrew@x-fifteen.com@mail.x-fifteen.com/INBOX.imapmbox/Messages/311201.emlx Mon Sep 21 19:27:49 2009 /Users/andrew/Library/Mail/Envelope Index
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
find $HOME -type f -print "%+\t%f\n" | sort -n
this is a good approximation, although there's something different between find's notion of atime and perl's...I'm probably missing something...find $HOME -type f -print "%+\t%f\n" | sort -n
If think you meant:find $HOME -type f -printf "%+\t%f\n" | sort -n
The printf option is not available on OS X (and I don't think on BSD). One could use:find $HOME -type f -exec printf "format" {} \; | sort -n
but I have 350,000 files in $HOME, and therefor 350,000 subshells. Slow. On Linux with -printf available as an option for find, your solution works well -- I think. I do not have Linux to test.