From owner-freebsd-questions@FreeBSD.ORG Tue Mar 6 00:42:11 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 47CBA16A401 for ; Tue, 6 Mar 2007 00:42:11 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from ayn.mi.celestial.com (hayek.celestial.com [192.136.111.12]) by mx1.freebsd.org (Postfix) with ESMTP id 2A5D713C491 for ; Tue, 6 Mar 2007 00:42:11 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from localhost (localhost [127.0.0.1]) by ayn.mi.celestial.com (Postfix) with ESMTP id 871E968942EA7; Mon, 5 Mar 2007 16:42:34 -0800 (PST) X-Virus-Scanned: amavisd-new at mi.celestial.com Received: from ayn.mi.celestial.com ([127.0.0.1]) by localhost (ayn.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ILzXWwKBVsbQ; Mon, 5 Mar 2007 16:42:34 -0800 (PST) Received: by ayn.mi.celestial.com (Postfix, from userid 203) id 62F24685FFE9F; Mon, 5 Mar 2007 16:42:34 -0800 (PST) Date: Mon, 5 Mar 2007 16:42:34 -0800 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20070306004234.GA15353@ayn.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <20070306003506.GA12553@thought.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070306003506.GA12553@thought.org> User-Agent: Mutt/1.5.11 OpenPKG/2.5 Subject: Re: awk question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@celestial.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2007 00:42:11 -0000 On Mon, Mar 05, 2007, Gary Kline wrote: > > Guys, > > Having found $9 , how do I /bin/rm it (using system()--yes??) > in an awk one-liner? > > 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? A better way to do this might be to use find and xargs. The command below would remove all files under the current directory that haven't been modified in the 360 days. find . -type f -mtime +360 -print0 | xargs -0 rm If you don't want it to go into subdirectories: find . -maxdepth 1 -type f -mtime +360 -print0 | xargs -0 rm Bill -- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 ``Anyone who thinks Microsoft never does anything truly innovative isn't paying attention to the part of the company that pushes the state of its art: Microsoft's legal department.'' --Ed Foster, InfoWorld Gripe Line columnist