Search this Website

 

Ubuntu

UNIX

delete files using awk

Category: UNIX-Unix Beginner

delete files using awk

the code below works for finding files created in 2005 that are compressed.
how do i delete these files?
do i substitute rm -f for the print $0 ?

here's the code that finds the 2005 compressed files

(ls -lr | awk '$8 == "2005" && $9 ~ /z$/ {print $0}')

thanks for your help!!!



try system()...though i am not sure how exactly to do it!


you can use find instead

code:

find /dir -type f -name "*.z" -ls | awk '$10 == "2005" {print $nf}' | xargs rm[img]http://www.unix.com/images/buttons