command to strip suffix in .sh script
Matthew Seaman
m.seaman at infracaninophile.co.uk
Wed Jun 2 08:30:31 UTC 2010
-----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 at 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-----
More information about the freebsd-questions
mailing list