用于检查ubuntu版本然后复制文件的Shell脚本 [英] Shell script to check ubuntu version and then copy files
本文介绍了用于检查ubuntu版本然后复制文件的Shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 shell 脚本编程的新手.我想写一个简单的shell脚本来检查系统中安装的ubuntu版本;如果版本大于或等于版本 12,则复制一些文件,如果版本小于或等于版本 12,则复制一些其他文件.
I am new to shell script programming. I want to write a simple shell script to check the ubuntu version installed in the system; if the version is greater than or equal to version 12 then copy some files, and if it's less then copy some other files.
推荐答案
lsb_release -rs
命令可以让我们确定 Ubuntu 版本,我们可以这样使用:
The lsb_release -rs
command lets us determine the Ubuntu version, we could use it like this:
if [[ $(lsb_release -rs) == "18.04" ]]; then # replace 8.04 by the number of release you want
echo "Compatible version"
#Copy your files here
else
echo "Non-compatible version"
fi
``(封闭反引号)是非 POSIX 且已弃用.
`` (enclosing backticks) is non-POSIX and deprecated.
这篇关于用于检查ubuntu版本然后复制文件的Shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文