bash脚本: 下载并安装vscode - 2021-02-08

save_path="./rpms"
download_url="https://go.microsoft.com/fwlink/?LinkID=760867"

mkdir -p $save_path
aria2c -d $save_path -c  $download_url

unset -v latest
for file in "${save_path}"/*; do
    if  [[ $file -nt $latest ]] ; then
        if [ -n "$latest" ] ; then  
            echo "${latest} 是老版本,现在删除..." 
             rm $latest 
        fi
        latest=$file
     fi
done
echo "最新版本:"
echo $latest
echo "下面开始安装..."
sudo dnf install $latest
unset save_path
unset download_url
unset latest

你可能感兴趣的:(bash脚本: 下载并安装vscode - 2021-02-08)