alonewolf
alonewolf

Reputation: 1

What do I miss (while-loop)?

I try to built a Programm where I can create Text-Files and folders. The user can type in i.a. the directory. To check if the given path exits I created a while-loop but it doesn’t work. My question is where are my errors and how can I fix them.

while [[ test -e $path == false]] 
do echo “type in a valid path”
read -r path
done 

Error:

./Create: line 28: conditional binary operator expected
./Create: line 28: syntax error near `e'
./Create: line 28: `while [[ test -e $path == false ]]'

Upvotes: 0

Views: 64

Answers (1)

Hai Vu
Hai Vu

Reputation: 40688

I found a couple of issues:

  1. You should use [[ or test, but not both
  2. false is not a constant in bash

The fix:

while [[ ! -e $path ]]
do
    ....
done

Upvotes: 4

Related Questions