command to strip suffix in .sh script
Adam Vande More
amvandemore at gmail.com
Wed Jun 2 08:40:29 UTC 2010
On Wed, Jun 2, 2010 at 3:24 AM, Matthias Apitz <guru at unixarea.de> 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/-.*$//'
>
>
One more
echo 'archivename-201006021514.34.tar.gz' | awk -F - '{print $1}'
--
Adam Vande More
More information about the freebsd-questions
mailing list