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

Re: Excluding certain directories

On Aug 20,  9:05am, Chris Johnson wrote:
} zzapper sent me the following 0.2K:
} > I want to exclude subdirectories dev*
} > ls {^dev*,}/index.php(.N)

ZZapper, Did you really mean to include the "/index.php" (a file in the
root directory "/") in the pattern?  I suspect you wanted

    ls {^dev*/,}index.php(.N)

Even so that's a bit of an odd pattern, because the (.N) will mean that
you run "ls" with no arguments if there is no file index.php.  Usually
one would only use (N) with a pattern in the path tail.

} Here's one approach:
}    ls -d **/*~**/dev/*~**/dev
} It's not entirely correct, since you can have a plain file named dev
} that's ignored by the last clause.

It's also not correct because "dev*" is not the same as "dev/*".

If you have extendedglob set (which you must if "^dev*" works), then
you can do this:

    ls **/index.php~dev*(/*)##

} It'd be nice to be able to embed
} glob qualifiers (/) into the negated pattern clauses, but it seems
} that's not supported.

Note that although the stuff to the left of the tilde (~) is a file
expansion, the stuff to the right of the tilde is a simple string match.
The "**/" construct doesn't mean anything (or rather, is no different
than "*/") in a string match.  Similarly, glob qualifiers don't mean
anything in a string match; but in a string match you can use # and ##
on a sub-pattern than contains a slash, which is meaningless in a glob.

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