Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Mar 2007 09:29:55 -0600
From:      Scott Oertel <freebsd@scottevil.com>
To:        Gary Kline <kline@tao.thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: awk question
Message-ID:  <45ED88F3.8040200@scottevil.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
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?
>
> 	thanks in advance,
>
> 	gary
>
>
>
>   

Another way is:

ls -lt | awk '{if ($8 == 2006) print "rm -rf "$9}' | sh

but I agree, using pkg_delete would be safer:

ls -lt | awk '{if ($8 == 2006) print "pkg_delete "$9}' | sh

-SO



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