Check if file exists in ksh

I wonder why the below tiny script is now working. I created dfFile under /data directory but script does not print the expressions in if statement.

#!/bin/ksh
DATAFILE="/data/dfFile"
echo $DATAFILE
#df -h>/data/dfFile if [[ -e DATAFILE ]] then echo "sa" echo $DATAFILE df -h > $DATAFILE fi
1

1 Answer

That should read

 if [[ -e "$DATAFILE" ]]
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like