zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zzapper <david@tvis.co.uk>
Cc: zsh-users@sunsite.dk
Subject: Re: Excluding files & directories from a glob
Date: Tue, 4 Oct 2005 17:14:38 +0100	[thread overview]
Message-ID: <20051004171438.4165d915.pws@csr.com> (raw)
In-Reply-To: <t495k1hltml46t91vsedbah8n6h2knijgg@4ax.com>

zzapper <david@tvis.co.uk> wrote:
> The following works just fine
> 
> # grep all coldfusion files except ctpigeon.cfm and env.cfm
> 
> grep -i 'host' **/(*.cfm~(ctpigeonbot|env).cfm)
> 
> But I would like it to also ignore sub-directories named junk*

With extendedglob, the following should work:

  grep -i 'host' **/(*.cfm~(ctpigeonbot|env).cfm)~*((#s)|/)junk*/*(.)

This excludes any pattern which {either starts with junk or contains /junk}
and {contains a / somewhere after the junk}.  Clearly that would only apply
if somewhere in the path there was a subdirectory starting "junk".

I tacked the next bit on at the end just to show the difference, but it's
possibly easier to combine the ~ expressions at the end.  However,
you would need to do the *((#s)|/)(ctpigeonbot|env).cfm trick to make sure
that the name only matched a full directory entry, either in the current
directory or a subdirectory.

You probably don't need the (.) on the end; it just wanted to be there.

Actually, most of my directories contain junk, so I won't be doing that...

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 69207


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


  reply	other threads:[~2005-10-04 16:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-04 15:53 zzapper
2005-10-04 16:14 ` Peter Stephenson [this message]
2005-10-04 18:25   ` zzapper
2005-10-05  3:01     ` Jean Chalard
2005-10-06  8:59       ` zzapper
2005-10-06  9:10         ` Jean Chalard
2005-10-06 10:23           ` zzapper
2005-10-06 10:52             ` Jean Chalard
2005-10-06 16:23               ` zzapper
2005-10-14 18:43   ` Hannu Koivisto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051004171438.4165d915.pws@csr.com \
    --to=pws@csr.com \
    --cc=david@tvis.co.uk \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).