Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Mar 2007 16:42:34 -0800
From:      Bill Campbell <freebsd@celestial.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: awk question
Message-ID:  <20070306004234.GA15353@ayn.mi.celestial.com>
In-Reply-To: <20070306003506.GA12553@thought.org>
References:  <20070306003506.GA12553@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070306004234.GA15353>