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

Re: list last modified files



On Thu, Aug 20, 2015 at 6:33 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Aug 19, 11:59pm, rooom wrote:
> }
> } I'm trying to write a function which lists 10 most recent files
> } from given sets (not only directories), something like trivial
> } `alias lt=ls -lat | head -n 10`, but better.
>
> You can't glob if this is an arbibrary list of files. A glob qualifier
> can only be applied to files within a single directory (unless you can
> use a recursive glob like **/*) because you can't mix directory
> traversal with grouping, that is, (dir1/*|dir3/*) is an error.  So you
> have to do one of --

You can do things like this though
% mkdir ab ac bc dc; () { touch $^@/{foo,bar} } ??
% echo ((ab|b?)/)#foo(e:'(( RANDOM < 16000 ))':)
ab/foo
% echo ((ab|b?)/)#foo(e:'(( RANDOM < 16000 ))':)
bc/foo

You just can't have a / inside a (foo|bar) group, which you do
potentially need sometimes. The pattern I used would also match
ab/bd/ab/bn/foo recursively.

-- 
Mikael Magnusson



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