Re: string pattern matching
From: Reinhard Skarbal (aon.912045243_at_aon.at)
Date: 07/09/03
- Next message: Stephane CHAZELAS: "Re: string pattern matching"
- Previous message: rakesh sharma: "Re: How to use negation with sed"
- In reply to: melissa_benkyo: "string pattern matching"
- Next in thread: Stephane CHAZELAS: "Re: string pattern matching"
- Reply: Stephane CHAZELAS: "Re: string pattern matching"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 9 Jul 2003 18:48:29 +0200
Try grep :
if echo $i | grep '^abc$' >/dev/null
then
print "found"
else
print "not found"
fi
( example for ksh )
regards
Reinhard
"melissa_benkyo" <wyl_lyf@yahoo.com> schrieb im Newsbeitrag
news:304f3217.0307090732.74cae060@posting.google.com...
> hello! I'd like to ask how to do this:
> I have a variable lets say
> test1[0]="abc"
> test1[1]="def"
> test1[2]="def | abc"
>
> How do I go about to test if the variable contains the exact pattern
string "abc"
>
> cause I tried to do
> for i in "${test1[@]}" ; do
> if [[ $i = ^abc$ ]] ; then
> echo "found it"
> fi
> done
>
> but this doesnt work. does anybody know how come? thanks!
- Next message: Stephane CHAZELAS: "Re: string pattern matching"
- Previous message: rakesh sharma: "Re: How to use negation with sed"
- In reply to: melissa_benkyo: "string pattern matching"
- Next in thread: Stephane CHAZELAS: "Re: string pattern matching"
- Reply: Stephane CHAZELAS: "Re: string pattern matching"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|