用于检查ubuntu版本然后复制文件的Shell脚本

aru*_*run -1 linux shell ubuntu

我是shell脚本编程的新手.我想写一个简单的shell脚本来检查系统中安装的ubuntu版本; 如果版本大于或等于版本12,则复制一些文件,如果版本少,则复制其他文件.

Pie*_*ter 16

一个小的谷歌搜索了解我们lsb_release -rs给我们ubuntu发布版本lsb_release -rs.现在您可以轻松使用if:

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
Run Code Online (Sandbox Code Playgroud)