Date: Mon, 7 Jan 2008 21:56:12 -0800 From: Bill Campbell <freebsd@celestial.com> To: freebsd-questions@freebsd.org Subject: Re: is there a /bin/sh method to tell the ending of a file Message-ID: <20080108055612.GA15798@ayn.mi.celestial.com> In-Reply-To: <20080108053408.GA95218@procacci.kicks-ass.org> References: <20080108051058.GA19698@thought.org> <20080108053408.GA95218@procacci.kicks-ass.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080108055612.GA15798>
