1
0
Fork 0
Public server tools, aliases, helpers, etc...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
202 B

4 months ago
#!/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