Date: Wed, 02 Jun 2010 09:30:18 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> 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: <4C06169A.9090604@infracaninophile.co.uk> 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
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 02/06/2010 09:24:01, Matthias Apitz wrote: > El día Wednesday, June 02, 2010 a las 04:15:22PM +0800, Aiza escribió: > >> I have this code >> >> archive_name=`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/-.*$//' archive_name=${fromarchive%-*} Cheers, Matthew - -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwGFpoACgkQ8Mjk52CukIz2IQCfRPPnh+1+Y12iY9dz5MeO0P++ 80QAnishOceHvFymn4S9miFK8lemmlHQ =99QV -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C06169A.9090604>