Hi,
I need to carry out the back up of the data if exists...(file size not equal to zero)
i tried in this way but it is not successful....where am making the mistakes? and if possible can i use case syntax in place of "if"
#!/bin/ksh
filename=`TZ=CST+24 date +%Y%m%d`
ZERO=0
SIZE_64=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-64.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_71=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-71.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_72=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-72.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_73=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-73.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_80=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-80.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_EZ=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-EZ.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_WZ=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-WZ.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_NZ=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-NZ.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_MTNL=$(ls -ltr /aemu/ErrorLogs/data/MissingCGI-MTNL.txt | tr -s ' ' | cut -d ' ' -f 5)
SIZE_COUNT=$(ls -ltr /aemu/ErrorLogs/data/MissingCGIcount.txt | tr -s ' ' | cut -d ' ' -f 5)
if [ $SIZE_64!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-64.txt /aemu/ErrorLogs/backup/CHN/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-64.txt > /aemu/ErrorLogs/data/MissingCGI-64.txt
elif [ $SIZE_71!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-71.txt /aemu/ErrorLogs/backup/KTK/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-71.txt > /aemu/ErrorLogs/data/MissingCGI-71.txt
elif [ $SIZE_72!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-72.txt /aemu/ErrorLogs/backup/KER/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-72.txt > /aemu/ErrorLogs/data/MissingCGI-72.txt
elif [ $SIZE_73!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-73.txt /aemu/ErrorLogs/backup/AP/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-73.txt > /aemu/ErrorLogs/data/MissingCGI-73.txt
elif [ $SIZE_80!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-80.txt /aemu/ErrorLogs/backup/TN/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-80.txt > /aemu/ErrorLogs/data/MissingCGI-80.txt
elif [ $SIZE_EZ!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-EZ.txt /aemu/ErrorLogs/backup/EZ/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-EZ.txt > /aemu/ErrorLogs/data/MissingCGI-EZ.txt
elif [ $SIZE_WZ!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-WZ.txt /aemu/ErrorLogs/backup/WZ/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-WZ.txt > /aemu/ErrorLogs/data/MissingCGI-WZ.txt
elif [ $SIZE_NZ!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-NZ.txt /aemu/ErrorLogs/backup/NZ/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-NZ.txt > /aemu/ErrorLogs/data/MissingCGI-NZ.txt
elif [ $SIZE_MTNL!=$ZERO ]
then
cp /aemu/ErrorLogs/data/MissingCGI-MTNL.txt /aemu/ErrorLogs/backup/MTNL/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGI-MTNL.txt > /aemu/ErrorLogs/data/MissingCGI-MTNL.txt
else [ $SIZE_COUNT!=$ZERO ]
cp /aemu/ErrorLogs/data/MissingCGIcount.txt /aemu/ErrorLogs/backup/COUNT/$filename
sleep 2
sed '' /aemu/ErrorLogs/data/MissingCGIcount.txt > /aemu/ErrorLogs/data/MissingCGIcount.txt
fi
exit
Aemunathan