From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12864 invoked from network); 21 Jan 2006 17:02:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Jan 2006 17:02:23 -0000 Received: (qmail 55328 invoked from network); 21 Jan 2006 17:02:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Jan 2006 17:02:16 -0000 Received: (qmail 27802 invoked by alias); 21 Jan 2006 17:02:07 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9844 Received: (qmail 27792 invoked from network); 21 Jan 2006 17:02:06 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Jan 2006 17:02:06 -0000 Received: (qmail 54196 invoked from network); 21 Jan 2006 17:02:06 -0000 Received: from vms048pub.verizon.net (206.46.252.48) by a.mx.sunsite.dk with SMTP; 21 Jan 2006 17:02:04 -0000 Received: from candle.brasslantern.com ([71.116.81.225]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0ITG00AB0CNE49L2@vms048.mailsrvcs.net> for zsh-users@sunsite.dk; Sat, 21 Jan 2006 11:02:03 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id k0LH21rB020035 for ; Sat, 21 Jan 2006 09:02:01 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id k0LH215T020034 for zsh-users@sunsite.dk; Sat, 21 Jan 2006 09:02:01 -0800 Date: Sat, 21 Jan 2006 17:02:01 +0000 From: Bart Schaefer Subject: Re: string starts with ... In-reply-to: <87oe254qx8.fsf@trews52.bothi.fi> To: zsh-users@sunsite.dk Message-id: <1060121170201.ZM20033@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20060121135331.GA557@antares.ba-leipzig.de> <87oe254qx8.fsf@trews52.bothi.fi> Comments: In reply to Hannu Koivisto "Re: string starts with ..." (Jan 21, 4:05pm) On Jan 21, 4:05pm, Hannu Koivisto wrote: } Subject: Re: string starts with ... } } Matthias Berndt writes: } } > how can I test if a string starts with '#'? } } [[ $YOURSTRING == \#* ]] } } See "Conditional Expressions" in the manual. I think the problem isn't understanding of conditional expressions, it's that '#' normally starts a comment, so you have to quote it. } > I can't find the trick. The "trick" is to quote ONLY the '#' character and not the rest of the pattern. Hence Hannu's solution is the most concise, but these work: [[ $YOURSTRING == '#'* ]] [[ $YOURSTRING == "#"* ]] String concatenation in shell language is by simple juxtaposition, no operator required. This works, too, by forcing the '#' to be treated as part of a pattern: [[ $YOURSTRING == (#)* ]]