From owner-freebsd-questions@FreeBSD.ORG Tue Jan 8 05:52:57 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF9F616A41A for ; Tue, 8 Jan 2008 05:52:57 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from ayn.mi.celestial.com (hayek.celestial.com [192.136.111.12]) by mx1.freebsd.org (Postfix) with ESMTP id 98EED13C43E for ; Tue, 8 Jan 2008 05:52:57 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from localhost (localhost [127.0.0.1]) by ayn.mi.celestial.com (Postfix) with ESMTP id 1968A68B706EF; Mon, 7 Jan 2008 21:56:13 -0800 (PST) X-Virus-Scanned: amavisd-new at mi.celestial.com Received: from ayn.mi.celestial.com ([127.0.0.1]) by localhost (ayn.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0oXHpS64lyzN; Mon, 7 Jan 2008 21:56:13 -0800 (PST) Received: by ayn.mi.celestial.com (Postfix, from userid 203) id F257368B451B0; Mon, 7 Jan 2008 21:56:12 -0800 (PST) Date: Mon, 7 Jan 2008 21:56:12 -0800 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20080108055612.GA15798@ayn.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <20080108051058.GA19698@thought.org> <20080108053408.GA95218@procacci.kicks-ass.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080108053408.GA95218@procacci.kicks-ass.org> User-Agent: Mutt/1.5.11 OpenPKG/2.5 Subject: Re: is there a /bin/sh method to tell the ending of a file X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@celestial.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jan 2008 05:52:57 -0000 On Mon, Jan 07, 2008, Paul Procacci wrote: >Is this what you mean? > >--------------------- >#!/bin/sh > >STRING="mystring.gz" > >if [ ".gz" = "`echo \"$STRING\" | sed -n 's/.*\(\.gz\)$/\1/p'`" ]; then > echo test; >fi Another way might be #!/bin/sh # basename $filename .gz returns $filename unless it has a .gz # suffix. [ `basename $filename .gz` = $filename ] || { echo $filename has a .gz suffix } Bill -- INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 Intellectually, teachers fall between education theorists and bright cocker spaniels. (Probably closer to the education theorists. The AKC has been doing wonders with spaniels.) If you think I'm kidding look at the GREs for education majors, whose scores are the lowest of all fields, and remember that these are the smart ones. -- http://www.FredOnEverything.net