From owner-freebsd-questions@FreeBSD.ORG Wed Feb 25 01:28:23 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 74D2416A4D7 for ; Wed, 25 Feb 2004 01:28:23 -0800 (PST) Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A5EE43D48 for ; Wed, 25 Feb 2004 01:28:22 -0800 (PST) (envelope-from mathias@haas.se) Received: from haas.se ([213.114.148.49] [213.114.148.49]) by mxfep01.bredband.com with SMTP id <20040225092817.HUBO13599.mxfep01.bredband.com@haas.se> for ; Wed, 25 Feb 2004 10:28:17 +0100 Received: (qmail 41700 invoked from network); 25 Feb 2004 09:34:06 -0000 Received: from mathias@haas.se by p3-550.haas.se by uid 82 with qmail-scanner-1.20 (spamassassin: 2.61. Clear:RC:1(127.0.0.1):. Processed: 34:06 -0000 Received: from localhost.haas.se (HELO mail.haas.se) (127.0.0.1) by: 34:06 -0000 Received: from 193.14.163.194 (SquirrelMail authenticated user mathias@haas.se) by mail.haas.se with HTTP; Wed,: 34:06 +0100 (CET) Message-ID: <50940.193.14.163.194.1077701646.squirrel@mail.haas.se> In-Reply-To: <20040224164004.11f27d1d.cpressey@catseye.mine.nu> References: <51804.193.14.163.194.1077641809.squirrel@mail.haas.se> <20040224164004.11f27d1d.cpressey@catseye.mine.nu> Date: Wed, 25 Feb 2004 10:34:06 +0100 (CET) From: mathias@haas.se To: "Chris Pressey" User-Agent: SquirrelMail/1.4.2 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal cc: questions@freebsd.org cc: mathias@haas.se Subject: Re: Shell scripting woes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2004 09:28:23 -0000 > On Tue, 24 Feb 2004 17:56:49 +0100 (CET) > mathias@haas.se wrote: > >> Hello guys! I have two questions about shellscripts: > > Your second question seems to have been addressed, so here's something > for your first question... > >> 1) I have a backup job that 'tar's a lot of files and currently I >> redirect all output of the job to a log. Tar unfortunately lists all >> directories that it goes through, even if nothing is 'tar'ed in those >> directories. So my logfile contains all my directories. I want to >> filter out all lines in my tar-log that ends with slash ("/") since >> those are directories. I want to sort of do an inverse grep on the >> last character when tarring. Like: tar -cvf myback.tar |grep -v "all >> lines that end with slash" > log.txt. All files that are backed up >> contain the whole directory path (that's how I want it) - so I can't >> simply do a reverse grep for the slash-char. Maybe you could do >> something with awk? I'm a total rookie with awk, so I'm lost there... > > Try > > tar -cvf myback.tar | grep -v '/$' > > The $ in the grep pattern indicates "end of line". > > -Chris Yes! That's exactly what I wanted! Thanks a lot! Cheers, Mathias