Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1974308
  • 博文数量: 356
  • 博客积分: 8284
  • 博客等级: 中将
  • 技术积分: 4580
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-15 20:25
个人简介

天行健,君子以自强不息

文章分类

全部博文(356)

文章存档

2018年(1)

2016年(4)

2015年(13)

2014年(14)

2013年(2)

2012年(25)

2011年(43)

2010年(65)

2009年(189)

分类: LINUX

2009-11-01 16:14:02

shell脚本的学习笔记

更改IP
vim 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


待续
阅读(1383) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~