写一个脚本,该脚本需要完成任务:
1)自动到ftp://192.168.0.254/pub/gls下载centos.repo到tmp目录下;
2)判断此文件是否存在,如果存在,则修改其中的baseurl1=http://mirrors.163.com为http://mirrors
.sohu.com,将修改后的文件移动到/etc/yum.repos.d/
3)安装一个软件pidgin;
脚本编写如下:
vim test.sh
#!/bin/bash
cd /tmp
lftpget ftp://192.168.0.254/pub/gls/centos.repo
if [ -e /tmp/centos.repo ];then
sed -i 's/163/sohu/g' centos.repo
else
echo "The file is not exist."
fi
mv /tmp/centos.repo /etc/yum.repos.d
yum install pidgin
保存退出;
赋予执行权限:chmod u+x test.sh
执行脚本: ./test.sh
转载于:https://blog.51cto.com/chenxizhuimeng/463943