Bash: Mengecek Architecture OS 32bit/64bit

Untuk mengecek architecture 32bit/64bit os yang menjalakan bash skrip dapat menggunakan archgetconfuname.

menjalankan di terminal:

$ arch
$ x86_64 #hasil

$ getconf LONG_BIT
$ 64 #hasil

$ uname -a
$ x86_64 #hasil

$ uname -i
$ x86_64 #hasil

bash skrip:

#!/usr/bin/env sh
if [ `arch` = "x86_64" ]; then
echo "64bit"
else
echo "32bit"
fi
#!/usr/bin/env sh
if [ `getconf LONG_BIT` = "64" ]; then
echo "64bit"
else
echo "32bit"
fi
#!/usr/bin/env sh
architecture=`uname -m`
if [ "$architecture" = "x86_64" ]; then
echo "64bit"
else
echo "32bit"
fi

Catatan:

  • untuk arch/uname apabila 64bit outputnya “x86_64“, apabila 32bit outputnya “i386“.
  • untuk getconf LONG_BIT outputnya langsung 64 atau 32.

Semoga bermanfaat.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s