1 | initial version |
The following script does the job:
#!/bin/bash
counter=0
for file in *
do
((counter++))
if (( $counter % 2 == 0 ))
then
rm "$file"
fi
done
2 | No.2 Revision |
The following script does the job:
#!/bin/bash
counter=0
for file in *
do
# Do not delete the script itslef
if [[ "$(basename -- "$0")" == "$file" ]]; then
echo "\$file is the filename of the current script."
continue
fi
((counter++))
if (( $counter % 2 == 0 ))
then
rm "$file"
fi
done