#!/bin/bash SAVEIFS=$IFS export IFS=$'\n'; CDIR=$(pwd) if (pwd | grep -c '\/home\/mobaxterm'); then #echo "Correct Directory" echo " " else echo "Recursive - Are you sure? CTRL-C now to terminate." # exit 0 sleep 4 fi echo " removing in order: .dddd.dd.dd .dd.dd.dddd .dd.dd.dd .19dd .20dd " for i in `find $CDIR -maxdepth 1 -type f -print`; do unset hasdate # echo echo "Looking at $i" hasfulldate=`echo "$i" | awk '/[\._][[:digit:]][[:digit:]][[:digit:]][[:digit:]][\._]/'` if [ -z "$hasfulldate" ] ; then hasfulldate=`echo ""` else hasdate=`echo "1"` fi if [ -z "$hasfulldate" ] ; then haspartialdate=`echo "$i" | awk '/[\._][[:digit:]][[:digit:]][\._][[:digit:]][[:digit:]]/'` if [ -z "$haspartialdate" ] ; then haspartialdate=`echo ""` else hasdate=`echo "1"` fi fi if [ -z $hasdate ] ; then unset hasdate else echo "found: $i " # in this order: # .dddd.dd.dd # .dd.dd.dddd # .dd.dd.dd # .19dd # .20dd # fi done IFS=$SAVEIFS