View Single Post

  #4 (permalink)  
Old 06-09-2008, 09:45 PM
Mats Mats is offline
Junior Member
User
 
Join Date: Jun 2008
My distro: Debian
Posts: 3
Rep Power: 0
Mats is on a distinguished road
Default 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
Reply With Quote