Reputation: 113
I have a directory named Directory_X and I want to check if it exists. I want to remove it, if it exists and create another directory named Directory_Y. I tried the below code, it is showing if:Expression Syntax error
if [ -d "Directory_X" ]; then
rm -rf Directory_X
mkdir Directory_Y
fi
Upvotes: 1
Views: 5486
Reputation: 121387
You are using POSIX sh syntax whereas your shell appears to be csh/tcsh. The if
statement syntax is different for tsch:
if ( ! -d "Directory_X" ) then
rm -rf Directory_X
mkdir Directory_Y
endif
Upvotes: 2