mv inside ksh script problem
folks;
I have a script to remove any files that older than 14 days then move any files that younger than 7 days to another directory. but for some reason it doesn't move the files, when i do it manually it works fine and find but not through the script. i tried 2 different ways in writing the move part but it didn't work with any of them. Any help is greatly appreciated
here it's:
cd /var/lib/mysql
files=$(find . \( -name 'mysql-bin.0*' \) -mtime +14 -print | sed 's+^\./++;s+/.*++' | sort -u)
if [ -z "${files}" ]; then
echo ""
echo "-------------------No SQL backup files to be removedi from the var directory -------------------------"
else
echo ""
echo ""
echo "...........Removing old files...................."
rm -rf ${files}
echo ""
echo ""
file=$(find . \( -name 'mysql-bin.0*' \) -mtime -7 -print | sed 's+^\./++;s+/.*++' | sort -u)
#mv `find . \( -name 'mysql-bin.0*' \) -mtime -7 -print | sed 's+^\./++;s+/.*++' | sort -u` /var/lib/mysql/backups/
mv ${file} /var/lib/mysql/backups/
sleep 1
fi
|