linux-shell编程笔记01
==============常用命令
env echo $path export ------------- cp mv mkdir rm ------------- cd ls ll ------------- more cat tail vi ------------- ifconfig getconf LONG_BIT df -h
==============shell语法
#!/bin/bash #test1 echo "Hello shell" echo `who` echo "who" ----------------------- #!/bin/bash #t2 echo "test 2" var1=1 var2=2 let var3=$var2+$var1 echo $var3 echo "end!" ----------------------- #!/bin/bash #t3 echo "test 3" echo "input first integer please:" read var1 echo "input second integer please:" read var2 let var3=var2+var1 echo $var1+$var2=$var3 echo "end!" ----------------------- #!/bin/bash #t4 echo "test 4" var1=$1 if [ $var1 -lt 0 ] then echo "illegal!" fi echo "end!" ----------------------- #!/bin/bash #t5 echo "test 5" var1=$1 if [ $var1 -lt 0 ] then echo "illegal!" else echo "Yeah!" fi echo "end!" ----------------------- #!/bin/bash #t6 echo "test 6" var1=$1 if [ $var1 -lt 0 ] then echo "illegal!" elif [ $var1 -lt 60 ] then echo "fail!" else echo "Yeah!" fi echo "end!" ----------------------- #!/bin/bash sum=0 for ((i=1;i<101;i++)) { let "sum+=i" } echo "sum=$sum" ----------------------- #!/bin/bash for animal in cat dog pig duck mice do echo $animal done ----------------------- #!/bin/bash sum=0 echo "input your number:" read num while(($num>0)) do let "sum+=num" let "num--" done echo "sum=$sum"
-------- 以上内容纯属个人学习总结,不代表任何团体或单位。若有理解不到之处请见谅!---------