Hello,
First, when you select "*log*", you
don't have to select "*.log*" beacause they are already in the first selection !
Second, why "touching" the file before deleting it ?
Third, your script will be runnig with "unable to remove file xxx" beacause of the command "rm -f $filestodelete" that will delete all the files selected by "for files in (*log*|*.log*)"
So, I propose you the script :
Code:
list=$(ls *log*)
for file in $list
do
cp $file $file.$(date +%a)
rm -f $file
done