From owner-freebsd-questions@FreeBSD.ORG Tue Jun 15 09:06:16 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 C066F1065677 for ; Tue, 15 Jun 2010 09:06:16 +0000 (UTC) (envelope-from aiza21@comclark.com) Received: from avmxsmtp3.comclark.com (avmxsmtp3.comclark.com [202.69.191.117]) by mx1.freebsd.org (Postfix) with ESMTP id 4FF968FC13 for ; Tue, 15 Jun 2010 09:06:15 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As4WAM7fFkzKRa1bPGdsb2JhbAAHh2iXDgEBAQE1J78WhRoEg00 X-IronPort-AV: E=Sophos;i="4.53,419,1272816000"; d="scan'208";a="3941315" Received: from unknown (HELO [10.0.10.3]) ([202.69.173.91]) by avmxsmtp3.comclark.com with ESMTP; 15 Jun 2010 17:06:14 +0800 Message-ID: <4C174283.9090903@comclark.com> Date: Tue, 15 Jun 2010 17:06:11 +0800 From: Aiza User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: "questions@freebsd.org" References: <4C173909.1050101@comclark.com> In-Reply-To: <4C173909.1050101@comclark.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 09:06:16 -0000 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.