[prev in list] [next in list] [prev in thread] [next in thread]
List: ast-users
Subject: Re: [ast-users] AND operator in shell syntax (equivalent to grep -X or ~(X))?
From: Dan Shelton <dan.f.shelton () gmail ! com>
Date: 2013-08-28 11:47:18
Message-ID: CAAvCNcBcBqjAbHRu_oX=kXydLqrJ-ks7Kj8EP5EOmZZaw5C6Og () mail ! gmail ! com
[Download RAW message or body]
On 21 August 2013 16:01, Glenn Fowler <gsf@research.att.com> wrote:
>
> On Tue, 20 Aug 2013 22:13:11 +0200 Dan Shelton wrote:
>> Does the Korn shell pattern syntax have an AND operator equivalent to
>> & in grep -X or ~(X)?
>
> here is an example using var expansion editing
>
> ksh -c 'v=abcd; print ${v/@(+([abc])&*([bcd]))/X}'
>
> you can see a more examples in the ast regex regression tests
>
> cd $PACKAGEROOT/src/cmd/re
> grep $'^K\t.*&' *.dat
>
> the *.dat file format man page is embedded in testregex.c in that same dir
>
> RE conjunction is typically combined with negation
> I use it this way a lot
>
> print rm @(*.c&!(precious.c))
>
> you can test ksh93 patterns with grep but be sure to use the -x option
> because shell glob pattern matching is anchored
>
> print $'foo.c\nprecious.c\nnotprecious.c' |
> grep -Kx '@(*.c&!(precious.c))'
>
> should produce
>
> foo.c
> notprecious.c
Thanks. I wish you'd have EXAMPLE sections in the manpage.
Dan
_______________________________________________
ast-users mailing list
ast-users@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic