1
0
Fork 0
server-tools-public/rmkeep

12 lines
202 B
Bash
Executable File

#!/bin/bash
MAXN=${2:-30}
num=$(ls -1rt | grep -- $1 | wc -l)
if [[ $num -lt $(($MAXN-1)) ]]; then
exit 1
fi
num=$(($num-$MAXN))
for fil in $(ls -1rt | grep -- $1 | head -n $num); do
rm -v $fil
done