现在感觉有点傻:
为什么我的条件总是正确的?
我试过了
# this should let me know what's not a directory or
# symbolic link.
whoa=`find ${MUSICDIR} ! -type l ! -type d | wc -l`
# I would expect if it's 0 (meaning nothing was found) that
# one of these statements would evaluate to false, but so far
# it's always evaluating to true
if [[ "${whoa}" != "0" ]]
do something
fi
if [[ ${whoa} -gt 0 ]]
do something
fi
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
事实证明,我在 if 语句之后遗漏了“then”。
应该
if [[ "${whoa}" != "0" ]]
then
do something
fi
Run Code Online (Sandbox Code Playgroud)