Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Sort directory tree contents by time completly ?



On Jan 12,  7:10am, Meino.Cramer@xxxxxx wrote:
} 
} Suppose there is a directory tree with very old, midaged and very
} ypung file in. There are also empty directories and symlinks.
} 
} Is it possible with zsh to get a directory listing of *all* files
} in kind of the output of "ls -l", where all files are in one
} long list, which is sorted by the timestamp of those files --

If there are not too many files, you can just do:

    ls -ldt **/*

This will work for up to a few thousand files depending on how deep
the directory tree is (i.e., how long the path names are).

If the above gives an "arguments too long" or similar error, try:

    print -Nr **/*(Om) | xargs -0 ls -ldt

You need to tell both zsh and ls to sort the same way or ls reorders
the groups of names fed it by xargs.

If you want oldest files first, use **/*(om) and ls -ldtr

You can also use zstat (from the zsh/stat module) to build the output
strings yourself instead of calling ls, but that's probably slower.



Messages sorted by: Reverse Date, Date, Thread, Author