shell脚本的学习笔记
更改IPvim changeto192
#!/bin/sh
ifconfig eth0 192.168.1.88 netmask 255.255.255.0 broadcast 192.168.1.111 up
保存退出,chmod +x changeto192 将IP更改为192.168.1.88 netmask 255.255.255.0 broadcast 192.168.1.111 up
#vim changeto10
#!/bin/sh
ifconfig eth0 10.10.208.88 netmask 255.255.255.0 broadcast 10.10.208.254 up
ifconfig eth0 down
ifconfig eth0 up
保存退出,chmod +x changeto10将IP更改为10.10.208.88 netmask 255.255.255.0 broadcast 10.10.208.254 up
以后每次要更改IP,只需执行脚本文件changeto10 和changeto192 即可
case语句的学习#!/bin/bash
echo
echo "1.restore"
echo "2.backup"
echo "3.unload"
echo
echo -n "Enter choice:"
read CHOICE
case "$CHOICE" in
1) echo "restore";;
2) echo "backup";;
3) echo "unload";;
*) echo "sorry,no such chioce!!!!"
exit 1
esac
删除文件或文件夹#!/bin/bash
first()
{
echo "=============================================================="
}
first
echo "please input the file you want to delete:"
read FILE
rm -rf $FILE
echo "the FILE $FILE has been deleted!"
echo "the remain files:"
ls
first
更改文件的权限(+x)
#!/bin/bash
echo -n "please choose the file that needed to be changed:"
read FILE
echo "the file you input is $FILE!"
chmod +x $FILE
ls -l
echo "The $FILE has been changed!(+X)"
更改文件的权限(-x)
#!/bin/bash
echo -n "please choose the file that needed to be changed:"
read FILE
echo "the file you input is $FILE!"
chmod -x $FILE
ls -l
echo "The $FILE has been changed!(-X)"
输入分数判断是否及格#!/bin/bash
echo "please input a score:"
read score
echo "your input score is $score"
if [ $score -ge 60 ];
then
echo "congratulation! you pass the examination."
else
echo "sorry, you faled the examination!"
fi
echo "press any key to continue!"
read $GOOUT
tftp_login(用ftp登录开发板)#!/bin/sh
ifconfig eth0 192.168.1.88 netmask 255.255.255.0 broadcast 192.168.1.111 up
ftp 192.168.1.230
tftp_logout(退出ftp登录)#!/bin/sh
ifconfig ifconfig eth0 10.10.208.88 netmask 255.255.255.0 broadcast 10.10.208.254 up
ifconfig
待续
阅读(1435) | 评论(0) | 转发(0) |