Sorting files by datestamp in Bash

You would think there were a function in Linux already that would do this.  The following command will sort all files in a directory and all subdirectories for the past 14 days by datestamp.

bash$ find . -mtime -14 -type f | while read line; do echo -n `ls -l --time-style='+%s %F %T' "$line" | awk '{print $6,$7,$8}'`; echo " $line"; done | sort | cut -d ' ' -f 1 --complement
Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
No Comments Posted in bash, Security
Tagged , ,

Leave a Reply


Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>