Hi,
Am trying to execute certain commands if the condition satisfied, but i feel i am making some mistakes in the usage of if statement
here is the code
#!/bin/ksh
SIZE=$(ls -ltr /aemu/ws/DN.txt | tr -s ' ' | cut -d ' ' -f 5)
filename=`TZ=CST+24 date +%Y%m%d`
ZERO=0
if [$SIZE=$ZERO ]
then
cp /aemu/ws/DN.txt /aemu/ws/backup/dn/$filename
echo $SIZE
fi
exit
am getting the error as
Aemunathan
Hi,
If you want to check the file size is zero or non zero , use the below code
[ -s filename ] && echo "Size" || echo "Zero Size"
Hi
How can i use it in IF statement ?
if [ -e $FILE ] && [ ! -s $FILE ]
(Reference )
pxy2d1
October 8, 2009, 4:08am
5
In your original code the problem is that you need a space between the first square bracket and variable name. Also the = is to assign not compare. Try
if [ $SIZE -eq $ZERO ]
Hi
Thanks...got it working....