String null space error: binary operator expected

When using - Z or - N to judge a variable empty, it should be noted that if you use the form of [- N ${Arg}] directly, if there are spaces in ${Arg} it will report an error

ARG="sd dd"
if [ -n ${ARG} ]; then
    echo 'ARG:' ${ARG}
    echo 'ARG is empty.'


line 27: [: sd: binary operator expected
ARG is empty.

Password> [- N ${Arg}] password> [- n “${Arg}]

Similar Posts: