Wednesday 16 November 2011

Search and Replace in awk

ls -R | gawk '{if($1 ~ /.*:$/){split($1,a,"/");if(a[length(a)] ~ /[a-z]/){if(length($1) > 10){print $1;}}}}' | awk '{ sub(/[:]$/, ""); print }' | xargs rm -rf

1 comment:

  1. search the sub directories and delete them .

    ex: /00/0a/abefe%sdfdsf:dfdsf - this file shall be deleted from the parent /00/0a/

    ReplyDelete