Can't see what I'm doing wrong

In:

# pwd
/usr/apps/vender/data/OSKPI

I have:

ls | grep 2013
-rw-r--r--   1 root     root          70 Feb 11 11:53 2-2013.dat

My code wants to either append or write new:

typeset -i MONTH=`date +%m`
MONTH=$(echo "$MONTH" | tr ' ')
typeset -i DAY=`date +%d`
DAY=$(echo "$DAY" | tr ' ')
typeset -i YEAR=`date +%Y`
YEAR=$(echo "$YEAR" | tr ' ')

FILE=$MONTH"-"$YEAR".dat"

if [-e /usr/apps/vender/data/OSKPI/$FILE]
  then
    echo $HOST","$DAY","$TIME","$CPU","$MEM","$SWAP","$LOAD >> /usr/apps/vender/data/OSKPI/$MONTH-$YEAR.dat
    echo "I did branch one"
  else
    echo $HOST","$DAY","$TIME","$CPU","$MEM","$SWAP","$LOAD > /usr/apps/vender/data/OSKPI/$MONTH-$YEAR.dat
    echo "I did branch two"
  fi
printf "\n" >> /usr/apps/vender/data/OSKPI/$MONTH-$YEAR.dat

No matter if I use -e or -f, the if statement does not see the existing file and does the "else"..

Can anyone tell me what I'm doing wrong?

Thanks,

Marc

Use spaces around the brackets:

if [ -e /usr/apps/vender/data/OSKPI/$FILE ]
1 Like

Can you post the exact output of your script...

Scrutinizer had it.
I'd discovered my mistake on a website and tested it. I was coming back here to say I'd figured it out and saw Scru's post.

I was not adding needed white space in the command