Bash:找不到命令

Ale*_*les 2 command-line bash scripts

我有一个需要了解处理器架构的脚本。我这样做:

if [["$(uname -m)" = "x86_64"]]; then
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
else
echo "Nossa! Você só pode usar 3,5GB de memória RAM. Que triste :( Vou baixar a versão 32bits pra você tá?"
wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.rpm
fi
Run Code Online (Sandbox Code Playgroud)

但是当我执行代码时,我收到:

instala_chrome.sh: line 35: [[x86_64: command not found
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题吗?谢谢!

hyt*_*omo 5

更好的使用:

if [[ "$(uname -m)" == "x86_64" ]]; then
Run Code Online (Sandbox Code Playgroud)

注意之间的空间[[和第一个参数两个=标志之间的空间,并"x86_64"]]

此外,将!echo包含在内也不是一个好主意:)

我认为这是进行此类操作时最好参考的地方:http : //mywiki.wooledge.org/BashPitfalls