awk question

Gary Kline kline at tao.thought.org
Tue Mar 6 16:54:18 UTC 2007


On Tue, Mar 06, 2007 at 07:27:56AM -0600, Derek Ragona wrote:
> You can loop through them using a shell script:
> for i in `ls -lt | awk '{if ($8 == 2006) print $9}'`;do rm $i;done


	This is the safest way to rm or rm -i each file ($i); the 
	ls -ls | [awkstuff] spits out the entire list in one chunk.
	But since packages from 2006 were OLD, I just /bin/rm'd them
	wholesale.  Thanks,

	gary

> 
>         -Derek
> 
> 
> At 06:35 PM 3/5/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?
> >
> >        thanks in advance,
> >
> >        gary
> >
> >
> >
> >--
> >  Gary Kline  kline at thought.org   www.thought.org  Public Service Unix
> >
> >_______________________________________________
> >freebsd-questions at freebsd.org mailing list
> >http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> >To unsubscribe, send any mail to 
> >"freebsd-questions-unsubscribe at freebsd.org"
> >
> >--
> >This message has been scanned for viruses and
> >dangerous content by MailScanner, and is
> >believed to be clean.
> >MailScanner thanks transtec Computers for their support.
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> MailScanner thanks transtec Computers for their support.
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

-- 
  Gary Kline  kline at thought.org   www.thought.org  Public Service Unix



More information about the freebsd-questions mailing list