如何使用 shell 脚本查找 Linux 发行版名称? [英] How to find Linux Distribution name using shell script?
本文介绍了如何使用 shell 脚本查找 Linux 发行版名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个 shell 脚本,我需要在其中使用当前操作系统名称来使其通用.喜欢:
I am writing a shell script in which I need the current operating system name to make it generic. Like:
if [ $Operating_System == "CentOS" ]
then
echo "CentOS";
# Do this
elif [ $Operating_System == "Ubuntu" ]
then
echo "Ubuntu";
# Do that
else
echo "Unsupported Operating System";
fi
这怎么可能?在 lsb_release -a
命令或其他东西上应用正则表达式?
How will it be possible? Applying regular expression on lsb_release -a
command or something else?
谢谢..
推荐答案
$ lsb_release -i
Distributor ID: Fedora
$ lsb_release -i | cut -f 2-
Fedora
这篇关于如何使用 shell 脚本查找 Linux 发行版名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文