作业

写个脚本,完成以下任务:
自动到ftp://192.168.0.254/pub/gls/centos.repo下载到目录
判断此文件是否存在,如果存在,则修改其中的baseurl=http://mirrors.163.com/centos为http://mirrors.sohu.com/centos,将修改后的文件移至/etc/repos.d/
安装一个软件pidgin

#!/bin/bash
cd /tmp
wget ftp://192.168.0.254/pub/gls/centos.repo
[ -e /tmp/centos.repo ]
if [ $? -eq 0 ];then
sed -i  s/baseurl=.*/baseurl=http:\/\/mirrors\.sohu\.com\/centos/g /tmp/centos.repo
mv /tmp/centos.repo /etc/yum.repos.d/
yum install pidgin -y
else
echo "the centos.repo is not exists"
exit 6
fi
 

 

100以内偶数和
#!/bin/bash
let SUM=0
for I in {0..50}
do
I=$I*2
let SUM+= $I
done
echo "the SUM is $SUM"

 

判断一个用户是否存在 并查看其默认shell脚本
#!/bin/bash
USER=`cat /etc/passwd |grep "^$1\>" |cut -d" -f7 `
id "$1" &> /dev/null
if [ $? -eq 0 ] ; then
echo "the $1 is exist,the shell is $USER"
else
echo "the $1 is not exist, please give me a true name"
fi

 


输入文件名,是否为普通文件,是则显示行数
#!/bin/bash
read "please give me a file name :"FILE
[ -f $FILE ]
if [ $?  -eq 0 ]; then
cat $FILE |wc -l
else
echo "you fool ,this isn't a common document"
fi
 

你可能感兴趣的:(职场,脚本,作业,休闲)