EN
Bash - detect machine architecture (Intel/AMD, x86/x64, 32bit/64bit)
8 points
In this short article, we would like to show how to check used machine architecture (Intel/AMD, x86/x64, 32bit/64bit) under Bash.
⚠️ Warning ⚠️: this solution works only for x86/x64 processors.
Quick solution:
xxxxxxxxxx
1
2
3
case "$(uname -m)" in
4
amd64) echo '64bit' ;;
5
x86_64) echo '64bit' ;;
6
i686-64) echo '64bit' ;;
7
x86) echo '32bit' ;;
8
x86pc) echo '32bit' ;;
9
i386) echo '32bit' ;;
10
i686) echo '32bit' ;;
11
i686-AT386) echo '32bit' ;;
12
# ...
13
# Add other cases here ...
14
# ...
15
*) echo 'unknown' ;;
16
esac
arch
command prints machine hardware name same as uname -m
command.
xxxxxxxxxx
1
2
3
case "$(arch)" in
4
amd64) echo '64bit' ;;
5
x86_64) echo '64bit' ;;
6
i686-64) echo '64bit' ;;
7
x86) echo '32bit' ;;
8
x86pc) echo '32bit' ;;
9
i386) echo '32bit' ;;
10
i686) echo '32bit' ;;
11
i686-AT386) echo '32bit' ;;
12
# ...
13
# Add other cases here ...
14
# ...
15
*) echo 'unknown' ;;
16
esac