#! /bin/bash
if [ !\(-f new.bash -o -d new.bash\) ]
then
echo "Neither"
else
echo "yes"
fi
它的工作原理,但留下一個錯誤:爲什麼shell腳本給我提供了太多的參數錯誤?
/file_exist_or_not.bash
./file_exist_or_not.bash: line 3: [: too many arguments
yes
BTW,爲什麼內parenthesises需要轉義?
感謝您的解釋,這對我有意義,你能告訴我爲什麼內括號需要逃脫嗎? – mko
否則bash將首先看到內部圓括號,並嘗試解釋它們本身,而不是將它們傳遞給'test'。 –
+1清除它 – mko