From owner-freebsd-questions@FreeBSD.ORG Tue Mar 6 00:58:22 2007 Return-Path: X-Original-To: freebsd-questions@FreeBSD.ORG Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3828916A401 for ; Tue, 6 Mar 2007 00:58:22 +0000 (UTC) (envelope-from kline@tao.thought.org) Received: from tao.thought.org (dsl231-043-140.sea1.dsl.speakeasy.net [216.231.43.140]) by mx1.freebsd.org (Postfix) with ESMTP id D209313C441 for ; Tue, 6 Mar 2007 00:58:21 +0000 (UTC) (envelope-from kline@tao.thought.org) Received: from tao.thought.org (localhost [127.0.0.1]) by tao.thought.org (8.13.8/8.13.1) with ESMTP id l260wKvG012746; Mon, 5 Mar 2007 16:58:21 -0800 (PST) (envelope-from kline@tao.thought.org) Received: (from kline@localhost) by tao.thought.org (8.13.8/8.13.1/Submit) id l260wKiH012738; Mon, 5 Mar 2007 16:58:20 -0800 (PST) (envelope-from kline) Date: Mon, 5 Mar 2007 16:58:20 -0800 From: Gary Kline To: Chuck Swiger Message-ID: <20070306005820.GC12600@thought.org> References: <20070306003506.GA12553@thought.org> <880C4678-6B40-44C7-A643-4F2FD9F35DBC@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <880C4678-6B40-44C7-A643-4F2FD9F35DBC@mac.com> User-Agent: Mutt/1.4.2.2i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: Observing twenty years of service to the Unix community Cc: Gary Kline , FreeBSD Mailing List Subject: Re: awk question 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: Tue, 06 Mar 2007 00:58:22 -0000 On Mon, Mar 05, 2007 at 04:46:35PM -0800, Chuck Swiger wrote: > On Mar 5, 2007, at 4:35 PM, Gary Kline wrote: > > Having found $9 , how do I /bin/rm it (using system()--yes??) > > in an awk one-liner? > > I gather that you are looking under /var/db/pkg...? > > >I'm trying to remove from packages from long ago and find and > > print them with > > > > ls -lt | awk '{if ($8 == 2006) print $9}'; > > > > but what I want to remove the file pointed at by $9. I've tried > > FILE=ARGV[9]; and using FILE within my system() call, but no-joy. > > What's the magic here? > > You could pipe the output of awk through "| xargs rm -rf"...but be > careful. > Putting it through "pkg_delete (-f)" might be safer. > Bill and Chuck: These are a slew of packages from 2006. (Obv'ly in /usr/ports/packages. I plumb fergot about xargs (again); just rarely use it. ls -lt | awk Foo catches those that are almost certainly invalid, from '06) but the find -mtime [days] is another way. Like they say about perl, there's always more than one way... When you've got Unix, you've got power at your fingertips. thanks, gents, gary > -- > -Chuck > -- Gary Kline kline@thought.org www.thought.org Public Service Unix