Reputation: 85
I wanted to recursively search a directory for a particular file extension, and wanted the files to appear by timestamp (i.e. newest ones first).
Ideally, I'd want something like:
ls -R -lth *.txt
but this doesn't work, although parts of it work:
ls -lth *.txt
ls -R -lth
How do I need to modify my 'ls' command?
thanks!
Upvotes: 0
Views: 619
Reputation: 111
I prefer this, because it also works with a large number of files
find . -name '*.txt' -printf '%T@ %t %p\n' | sort -k 1 -n
Upvotes: 0
Reputation: 4708
If you're using bash
, you could enable the globstar
shell option and use **/
to match zero or more subdirectories:
shopt -s globstar # enable globstar
ls -lth **/*.txt
shopt -u globstar # disable globstar
Upvotes: 1