From owner-freebsd-questions@FreeBSD.ORG Wed Jun 2 08:40:29 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 455761065679 for ; Wed, 2 Jun 2010 08:40:29 +0000 (UTC) (envelope-from amvandemore@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id ED7F08FC1A for ; Wed, 2 Jun 2010 08:40:28 +0000 (UTC) Received: by vws10 with SMTP id 10so4736062vws.13 for ; Wed, 02 Jun 2010 01:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=Ly5MM2J/1dqy3VFbLdFrQMU5uTBkalSq4H9uSh5LSTM=; b=TDETLqxG7ERp5pE9J3acTOayxbZ9wAHfkIoUpM6k5GbY5I+/36Be+gj2ADb1XMVNfc HX3mVpoc/FO7TW2grbpx28DAMVC3YnBaIQfcJv7iJv/BhrD/UE/hQQbYrJOL6kim+b6R h5eBOAsszhQj59Ip57hqRAVX9fvgvvDD9wcR0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=VPArnDgGEk2CKM6Lj5USviX2L2micZlszwxoN12tfzUq5YnC8iPLsYzzUYeihEO57r xhADUljS5vkAHwELgfEEPr5uO00Kbi2fQp9l/I9x9w84qx+b3gKFtpauHxoNgc4XHWed /k/rhN25Vz33rG8tmIQOkPExwt9/jjonb5B5o= MIME-Version: 1.0 Received: by 10.224.78.204 with SMTP id m12mr3047866qak.371.1275468027950; Wed, 02 Jun 2010 01:40:27 -0700 (PDT) Received: by 10.229.99.67 with HTTP; Wed, 2 Jun 2010 01:40:27 -0700 (PDT) In-Reply-To: <20100602082401.GA2876@current.Sisis.de> References: <4C06131A.6010107@comclark.com> <20100602082401.GA2876@current.Sisis.de> Date: Wed, 2 Jun 2010 03:40:27 -0500 Message-ID: From: Adam Vande More To: Matthias Apitz Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Aiza , "questions@freebsd.org" Subject: Re: command to strip suffix in .sh script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2010 08:40:29 -0000 On Wed, Jun 2, 2010 at 3:24 AM, Matthias Apitz 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