<分区>
我是 shell 脚本的新手,因为我要检测 linux 的版本? 使用 shell 脚本将检测版本是 5 还是 6 Linux 如果可能的话使用 IF 执行安装 block 。
<分区>
我是 shell 脚本的新手,因为我要检测 linux 的版本? 使用 shell 脚本将检测版本是 5 还是 6 Linux 如果可能的话使用 IF 执行安装 block 。
最佳答案
使用 lsb_release -r | cut -f2
以获得您的发行版? (并使用不同的分隔符再次 cut
以提取版本的主要编号)
例如:
version=`lsb_release -r | cut -f2 | cut -d. -f1`
if [ ${version} = 5 ]; then
echo "This is version 5"
elif [ ${version} = 6 ]; then
echo "This is version 6"
fi
关于linux - 检测 linux 版本 5 或 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21390196/