Are you hiding the error reports or did you fix the syntax errors meantime?
(0)'s syntax is:
[ arg1 arg2 ... argN ]
Blanks are needed.
All arguments must
. « !-d
« is wrong for instance.
» should be an argument, as should « -d
is a command that excepts to see arguments ended by a not optional ]
to delimit its end. (Symmetry involved.)==
as a special [
(0)'s operator isn't defined by POSIX standards; =
In your current cases, you want to check whether the variable holding the user's input is empty
before supplying it to grep
(1), otherwise it will report that there is no pattern to search for.
Though, the following is a better way to do the same thing:
if cut -d';' -f1 /path/to/file | grep -Fxq "$var"; then
Also, you should double-quote every variable expansion when in doubt.