For condition logic answer are incorrect
if [ -d “/home/bob/caleston” ]
then
echo “Directory exists”
else
echo “Directory not found”
I copied answer and ran it.
same for fallowing question syntax error:
if [ $1 -gt $2 ]
then
echo $1
else
echo $2
Hello, @volodymyr
I think you forgot to close if
condition with fi
.
Simple pattern:
if
<statement>
else
<statement>
fi
thank you for the answer @Tej-Singh-Rana. that’s my thought too but i wanted to bring attention to platform administrators that they provided wrong answer in the file. confusing at first. As you see i’m doing cat on the provided answer and using that script as it is in the file to run.
So did you copy that answer file in the current location? Because you’re doing cat
to /tmp/assets/
directory.
i copied exact content copy past into the file made it executable and ran it.
I copied exact answer file and it’s working.
Oh is see my mistake. thank you.
Try as below
if [ -d “/home/bob/caleston” ]
then
echo “Directory exists”
else
echo “Directory not found”
fi