im trying to make a script that runs in crontab and removes the older file if the directory exceeds a specified amount of space
targetdir=/var/big/
in this directory i have some logs that have also names with spaces and this i cant delete with the method i have tried
i have done something like this
Code:
nofiles=`ls | wc -l`
if [ $nofiles -ne 0 ] ; then
listf="`ls -tr | head`" #to get the older files, and then
echo " - deleting $listf"
/bin/rm -fr $listf
else
echo "blabla"
fi
so if i have some files with spaces in there names they wont be removed and the script will hang
how can i make it delete this files to?
at first i was thinking to put the filename between "", but its not working
thanks in advance
BR