From owner-freebsd-questions@FreeBSD.ORG Tue Jun 15 16:25:11 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03F08106567C for ; Tue, 15 Jun 2010 16:25:11 +0000 (UTC) (envelope-from sterling@camdensoftware.com) Received: from wh2.interactivevillages.com (wh2.interactivevillages.com [75.125.250.34]) by mx1.freebsd.org (Postfix) with ESMTP id D0AEF8FC14 for ; Tue, 15 Jun 2010 16:25:10 +0000 (UTC) Received: from 174-21-99-21.tukw.qwest.net ([174.21.99.21] helo=_HOSTNAME_) by wh2.interactivevillages.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1OOYon-0007B8-EV for questions@freebsd.org; Tue, 15 Jun 2010 09:16:54 -0700 Received: by _HOSTNAME_ (sSMTP sendmail emulation); Tue, 15 Jun 2010 09:25:05 -0700 Date: Tue, 15 Jun 2010 09:25:05 -0700 From: Chip Camden To: "questions@freebsd.org" Message-ID: <20100615162505.GB31149@libertas.local.camdensoftware.com> Mail-Followup-To: "questions@freebsd.org" References: <4C173909.1050101@comclark.com> <4C174283.9090903@comclark.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C174283.9090903@comclark.com> User-Agent: Mutt/1.4.2.3i Company: Camden Software Consulting URL: http://camdensoftware.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - wh2.interactivevillages.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - camdensoftware.com Cc: Subject: Re: * wildcard in.sh script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jun 2010 16:25:11 -0000 On Jun 15 2010 17:06, Aiza wrote: > Aiza wrote: > >I have a directory with files in it. The first 3 letters of the file > >names is the group prefix. I'm trying to write a script to accept the 3 > >letter of the group followed by a * to mean its a prefix lookup. But > >when I run it I get a message "NO match" that is not issued by the > >script. Its like * is not allowed as input. > > > >Looking for sample .sh code for handling this standard type of lookup or > >some online tutorial that has sample code for bourne shell programming. > > > > > > Here is the code > > prefix_name1=$1 > prefix_name2=`echo -n "${prefix_name1}" | sed 's/*.*$//'` > echo "prefix_name1 = ${prefix_name1}" > echo "prefix_name2 = ${prefix_name2}" > > > if [ ${prefix_name1} -nq ${prefix_name2} ]; then > echo "prefix_name2 = ${prefix_name2}" > fi > exerr "hard stop" > > > Here is the test and out put > # >admin cell* > admin: No match. > As others have mentioned, you need to quote or escape the * in the command line: admin "cell*" You've also botched your regex (/*.*$/) -- it can't begin with a *. What exactly are you trying to match? -- Sterling (Chip) Camden http://camdensoftware.com | http://chipstips.com | http://chipsquips.com