0
試圖寫一個bash,如果定義了環境變量中指定要使用的命令。這樣做如下:Bash沒有這樣的文件或目錄
if [ -z $MY_DIFF ];
then
echo Using standard diff $(which diff), change MY_DIFF env variable to use a different one.
echo $(which diff)
$diffv=$(which diff)
else
$diffv=$MY_DIFF
fi
$diffv c.xml c2.xml
但我發現了:
./bash.sh: line 10: =/opt/gnu/bin/diff: No such file or directory
./bash.sh: line 13: c.xml: command not found
我敢肯定,該文件存在,我也有權執行。任何想法可能是什麼問題?
您可以包括行號更清楚地顯示在錯誤指向? –
您在diff路徑前有一個'='。 – blackSmith
請勿在作業左側使用$(在腳本上運行時,這是從[ShellCheck](http://www.shellcheck.net)輸出的文字)。 –