I have a folder, we'll call it /scripts/, that contains subfolders for a number of different scripts (let's say /scripts/file_export, /scripts/record_ingest, /scripts/stats). Inside these folders are all kinds of things...shell scripts, perl scripts, ruby scripts, config files, etc. Some have their own directory structure, some have everything in their root. I saw this question and thought I could run that command inside a for loop, but I'm wondering if there's a more efficient way to write this using find and piping without just iterating over each folder in a loop. Ideas?

  • Don't make us chase links: please add the relevant info to this question. Oct 1, 2014 at 13:52

1 Answer 1


I'm not sure exactly what you want, but the following meets what you seem to be asking:

find . -exec ls -db --full-time {} \; | sed -e 's/^[^ ]* [^ ]* [^ ]* [^ ]* [^ ]* //' -e 's/ [+-][0-9][0-9][0-9][0-9]//' | sort

Any other directory could of course be used in the find, for example find /scripts/.

  • 1
    @onbrokenwingz - thanks for the edit, correcting my over-hasty update.
    – AFH
    Oct 1, 2014 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.