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

Re: ls most recent files in a hierarchy



On Mar 16,  2:46am, Christian Schneider wrote:
} Subject: Re: ls most recent files in a hierarchy
}
} > 2) list x most recent files in each directory of a hierarchy
} 
} ls **/*(D.om[1,5]) # 5 recent files

As Lloyd has pointed out, that's actually the answer to #3:

} > 3) list x most recent files in a hierarchy

The answer to #2 is less obvious:

  ls *(ND.om[1,5]) **/*(D/e:'reply=( $REPLY/*(ND.om[1,5]) )':)

That also requires a fairly recent version of zsh; none of the 4.2.x
series has the fix, they'll either crash or go into an infinite loop
when presented with the glob-within-a-glob.

For the 4.2.x line, you need something like:

  dirs=( '' **/*(DM/) ) eval 'ls ${^dirs}*(ND.om[1,5])'

which is perhaps clearer anyway and works in 4.3.x too.



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