Shell脚本入门(三)
批量修改文件结尾
#!/usr/bin/bash
#
#
for i in `cat *.html `
do
mv $i ${i%.html}.txt
done
【elif 多种情况条件判断】
#!/bin/bash
read -p "please input score to test level: "score
if [ $score -ge 90 ];then
echo "优秀"
elif [ $score -ge 80 ];then
echo "良好"
elif [ $score -ge 70 ];then
echo "中等"
elif [ $score -ge 60 ];then
echo "及格"
else
echo "不及格"
fi
【EOF 中间会给用户显示】
#!/bin/bash
cat << EOF
m|M) show memory usages
d|D) show disk usages
q|Q) quit
EOF
read -p "your choice" choice
case $choice in
m|M) free -m
;;
d|D) df -h
;;
q|Q) exit
;;
*) echo "Invalid input"
esac
#!/usr/bin/bash
web1=192.168.116.129
web2=192.1