On Wed, Jul 27, 2022 at 04:15:36PM +0200, Alexander Hall wrote:
> 
> 
> On July 27, 2022 3:47:56 PM GMT+02:00, Andrew Hewus Fresh 
> <and...@afresh1.com> wrote:
> >On Wed, Jul 27, 2022 at 11:06:39AM +0200, Alexander Hall wrote:
> >> I think replacing '*' with '*([![:cntrl:]])' can be the droid your looking 
> >> for.
> >
> >As I was falling asleep last night I was trying to figure out how to get
> >'*([!$_nl])' into the match and couldn't think of a good one.  Your
> >solution is much better.
> >
> >I think that would end up looking like: ^cpu0:*([![:cntrl:]])Intel(R)
> >although I recall some weirdness with metachars in a variable so I'll
> >have to test it out.
> 
> Yeah, it was pointed out to me. I was only able to test on ksh93, so that 
> might be a dead end.
> 
> /Alexander

$ cat u.sh
_s="cpu0: gen Intel"
_m="cpu0:*([![:cntrl:]])Intel"

if [[ $_s = *$_m* ]]; then
        echo T1 matched
fi

if [[ $_s = *cpu0:*([![:cntrl:]])Intel* ]]; then
        echo T2 matched
fi

$ ksh u.sh
T2 matched

$ ksh93 u.sh
T1 matched
T2 matched

$ bash u.sh
T1 matched
T2 matched

Reply via email to