天天看點

腳本

寫一個腳本,該腳本需要完成任務:

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

繼續閱讀