Think I solved it...
It works...
I also added so that only files that starts with Sqr is processed.
ThanX rockdalinux !!!
here is the script as of now :
#!/bin/bash
OUT="/tmp/list.$$"
c=0
pos=$1 # file position
dir=$2 # directory name
[ $# -ne 2 ] && exit 1 || :
find ${dir} -name Sqr\* -type f | sort -o $OUT
while read line
do
(( c++ ))
if [ $c -eq $pos ];
then
echo "Keeping $line at $c pos..."
# echo "/bin/rm $line"
c=0 # reset
else
echo "Deleting $line at $c pos..."
echo "/bin/rm $line"
/bin/rm $line
fi
done < $OUT
/bin/rm $OUT
|