三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

怎么编写一个shell脚本,用户输入软件包自动识别系统,然后安装

怎么编写一个shell脚本,用户输入软件包自动识别系统,然后安装
#!/bin/bash read -p "请输入要下载的软件包:" software source /etc/os-release if [ "$ID" = "centos" ] || [ "$ID" = "rhel" ];then yum install -y $software elif [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ];then apt-get install -y $software echo "$software 已经安装完成" else echo "请输入正确的软件包名" fi
← 返回列表