我似乎可以看到爲什麼這不起作用:Bash - IF [..] ||的麻煩結果[..]
#!/bin/bash
if [ $# -ne 1 ] || [ $# -ne 2 ]; then
# Should run if there are either 1 or 2 options specified
echo "usage: ${0##*/} <username>"
exit
fi
當測試,看看它的工作原理:
[email protected]:~# testing.sh optionone optiontwo
...Correct output...
[email protected]:~# testing.sh optionone
usage: testing.sh <username>
忽略了最低在所有的工作與代碼.. '根@ Ubuntu的:〜#testing.sh你好再見 用法: testing.sh root @ ubuntu:〜#testing.sh hello usage:testing.sh ' –
King
2012-02-26 02:16:32
我修復了答案;它現在應該爲你工作? – summea 2012-02-26 03:02:05
我導致只使用'if [$ {1}]然後echo「」else ... exit ...' – King 2012-02-26 04:46:44