From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15144 invoked from network); 13 Jan 2003 18:26:43 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 13 Jan 2003 18:26:43 -0000 Received: (qmail 9392 invoked by alias); 13 Jan 2003 18:26:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5690 Received: (qmail 9380 invoked from network); 13 Jan 2003 18:26:29 -0000 From: "Bart Schaefer" Message-Id: <1030113182602.ZM21860@candle.brasslantern.com> Date: Mon, 13 Jan 2003 18:26:02 +0000 In-Reply-To: <15907.432.363150.443412@fisica.ufpr.br> Comments: In reply to Carlos Carvalho "how to search for a substring in a parameter?" (Jan 13, 4:13pm) References: <15907.432.363150.443412@fisica.ufpr.br> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: how to search for a substring in a parameter? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 13, 4:13pm, Carlos Carvalho wrote: } } I'm trying to see if the value of a parameter contains a given string The right-hand-side of == in a [[ ]] construct is a glob pattern, so if all you want is true/false, this works: if [[ $foo == *pattern* ]]; then # contains pattern else # doesn't contain pattern fi If you want to extract the matching string, see the M and S flags: matching=${(SM)foo##pattern}