Results 1 to 3 of 3
I am trying to delete a file if it exists but I keep getting the following error:
"[-f: not found [No such file or directory]"
Is the syntax incorrect?
Code:
...
- 09-22-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 14
ksh: checking if file exists
I am trying to delete a file if it exists but I keep getting the following error:
"[-f: not found [No such file or directory]"
Is the syntax incorrect?
Code:#!/bin/ksh FILE="/tmp/file.sh" if [-e $FILE]; then rm $FILE fi
- 09-22-2008 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
You need to have a space after the '[' and before the ']'.
Code:#!/bin/ksh FILE="/tmp/file.sh" if [ -e $FILE ]; then rm $FILE fi
- 09-22-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 14
argh! Thanks so much!


Reply With Quote