1

I am trying to create a script to compare an inputted string to an empty value. The logic works, but I keep receiving the following error:

./demo.sh: line 13: [[/var: No such file or directory

Here is the code block that I am struggling with:

read -p "Hello, please enter the target installation path: [/opt] " depl echo "You have chosen to deploy in $depl" echo "Now deploying in $depl..." if [[$depl == ""]]; then echo "Invalid input, cannot write to root!" else sleep 2 mkdir $depl/new echo "Deployment complete!" fi 

I have tried adding my target inputs to $PATH which does not help. Everything else is working fine, but I am just not understanding why this error is being thrown. Any insight would be much appreciated!

5
  • 3
    You need spaces between [[ and $depl, and also between "" and ]]. And you should put double-quotes around $depl/new. shellcheck.net is good at spotting common mistakes like these. Also, stack overflow would be a much better place for scripting questions like this. Commented May 27, 2020 at 16:40
  • @GordonDavisson - thanks for your reply. I have already tried that combination, but I am still getting the same results. The script itself is actually working, but I just can't figure out where this error is coming from. Commented May 27, 2020 at 16:47
  • Update, I used the website you had suggested and apparently I had missing spaces before and after the brackets. Thanks! Commented May 27, 2020 at 16:48
  • @Reboot please close this Commented May 27, 2020 at 18:56
  • @GordonDavisson Thank you, spellcheck.net helped me a lot Commented Dec 26, 2020 at 14:53

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.