Friday, May 3, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2494  / 3 Years ago, sat, may 8, 2021, 7:40:06

I have a script that needs to know the processor architecture. I'm doing this way:



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


But when I execute the code, I receive:



instala_chrome.sh: line 35: [[x86_64: command not found


Anyone can help me to solve this? Thanks!


More From » command-line

 Answers
6

Better use:



if [[ "$(uname -m)" == "x86_64" ]]; then


Notice the space between [[ and first parameter, two = signs , and the space between "x86_64" and ]]



Also, it is not a good idea to include ! inside echo :)



I think that that's the best place to refer to when doing such operations: http://mywiki.wooledge.org/BashPitfalls


[#35834] Saturday, May 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calcur

Total Points: 189
Total Questions: 80
Total Answers: 95

Location: Burkina Faso
Member since Thu, Dec 15, 2022
1 Year ago
;