shell 電腦型別判斷(核心型別判斷)

2021-08-15 07:17:45 字數 626 閱讀 6794

當我們需要做一款相容不同平台的應用時,我們不得不考慮平台的相容性,

因此,我們有必要區分不同的核心,從而進行不同的操作。

下面將介紹如何利用shell對電腦的核心進行判斷

machine_type="$(uname -m)"

machine_is_64bit='no'

if [ "$" = 'amd64' -o "$" = 'x86_64' -o "$" = 's390x' ]; then

machine_is_64bit='yes'

fimachine_is_arm='no'

if [ "$" = 'arm' -o "$" = 'armv7l' -o "$" = 'aarch' ]; then

machine_is_arm='yes'

fimachine_is_z='no'

if [ "$" = 's390x' ]; then

machine_is_z='yes'

fiif [ "$" = 'ppc64' -o "$" = 'ppc64le' ]; then

machine_is_64bit='yes'

fi

以上**摘自github,

bazel原始碼

shell指令碼判斷檔案型別

1在shell中稱為 位置引數 表示傳入的第1個引數 第1個入參 test z 1 是乙個判斷表示式,用於判斷 1的值是否為空字串。雖然 linux 和 unix 的每個版本中都包含 test 命令,但該命令有乙個更常用的別名 左方括號 test 及其別名通常都可以在 usr bin 或 bin 取...

php 型別判斷

學習筆記 判斷陣列 colors array red blue green if is array colors 雙精度數判斷 temperature 15.23 if is double temperature 整數判斷 pagecount 2234 if is integer pagecount...

asp判斷型別

asp的工具有很多,asp的型別就是其中之一,好像asp的資料型別只有乙個那就是 variant 它是一種特殊的資料型別能夠根據它的使用表示很多不同種類的資訊。因為它是asp 中唯一的資料型別,它也是 asp中所有函式返回值的唯一型別。它很簡單的,variant 資料型別能夠表示數字或者是字串。當你...