Hi,
I have the following script to move the files from active directory to archive directory if the file system is 75% full. Everything works fine except the while loop does not get out when the condition is met. The script is moving files even after the FS is less than 75% full.
Any help is greatly appreciated.
df $SOURCEDIR | awk 'FNR==2{sub("%","",$4);print $4}' | read SOURCE_FS
if [ $SOURCE_FS -ge 75 ] ; then
echo "LOG files available to move"
while [ $SOURCE_FS -ge 75 ] ; do
ls -ltr|grep LOG|head -1|awk '\{print $9\}'|read SOURCE_FILE
mv $SOURCE/$SOURCE_FILE $TARGET
done
else
echo "Log files are unavailable to move"
fi
Thanks all.