Using the Mac OS X Terminal, how do I write a
find command that orders results by modification date (most recent first)?
There are similar questions already, but they refer to GNU
find and POSIX, but I do not know whether Mac OS X is GNU or POSIX or something else.
OS X is fully POSIX compliant.
Something like that should do:
find . -type f -name "*.txt" -print0 | xargs -0 ls -tl
lswill sort by
xargsis used to pass the filenames as an argument to
ls. Note that you have to use
xargsif you have files with spaces in their names. Also, the maximum amount of arguments is limited by the
ARG_MAXvariable. To find out how many these are, enter
- You can supply
-rto reverse the sort order (→ oldest files first)
- The other
lsoptions are – as usual – outlined in the manuals (