Date: Wed, 2 Jun 2010 03:40:27 -0500 From: Adam Vande More <amvandemore@gmail.com> To: Matthias Apitz <guru@unixarea.de> Cc: Aiza <aiza21@comclark.com>, "questions@freebsd.org" <questions@freebsd.org> Subject: Re: command to strip suffix in .sh script Message-ID: <AANLkTilwTDsgKwVCHPjFqr-6bvJKiAUGCb0pXGviDUbY@mail.gmail.com> In-Reply-To: <20100602082401.GA2876@current.Sisis.de> References: <4C06131A.6010107@comclark.com> <20100602082401.GA2876@current.Sisis.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 2, 2010 at 3:24 AM, Matthias Apitz <guru@unixarea.de> wrote: > El d=EDa Wednesday, June 02, 2010 a las 04:15:22PM +0800, Aiza escribi=F3= : > > > I have this code > > > > archive_name=3D`echo -n "${fromarchive}" | tr -c '[:alnum:]' _` > > > > ` is the key under Esc key and ' key is next to enter key. > > > > fromarchive value is archivename-201006021514.34.tar.gz > > > > I want to strip the suffix -201006021514.34.tar.gz from the archivename= . > > > > The archivename can be upper and lower case letters interspersed with _ > > > > > > Do I have syntax problem with the code? I get no error on it. > > > > Do I have the tr command coded correctly? > > > > Or should I be using something else instead of tr command? > > $ echo 'archivename-201006021514.34.tar.gz' | sed 's/-.*$//' > > One more echo 'archivename-201006021514.34.tar.gz' | awk -F - '{print $1}' --=20 Adam Vande More
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTilwTDsgKwVCHPjFqr-6bvJKiAUGCb0pXGviDUbY>