shell学习

学习shell编程,简单的写了一个shell脚本。
 
  1. #!/bin/bash
  2. # this is shell script test file ,just for study

  3. #1. if and test
  4. if test -f shell.sh
  5. then
  6.     echo -e "\n Hello shell \n"
  7. else
  8.     echo -e "\n No shell.sh file \n"
  9. fi

  10. #another test
  11. if [ -f shell.sh ]
  12. then
  13.     echo -e "\n Hello shell \n"
  14. else
  15.     echo -e "\n No shell.sh file \n"
  16. fi

  17. #2. for loop and echo
  18. for var in 1 2 3 "bash shell "
  19. do
  20.     echo -n $var
  21. done
  22. echo -e

  23. for var in 1 2 3 "bash shell" # -n -e diff
  24. do
  25.     echo -e $var
  26. done

  27. for var in 1 2 3 "bash shell" # -n -e diff
  28. do
  29.     printf $var
  30. done
  31. echo -e

  32. #3. while
  33. while [ "$0 != "untuntu" " ]
  34. do
  35.     echo -e "while loop"
  36.     break
  37. done

  38. #4. input
  39. echo -n "Please input usename :"
  40. read usename

  41. echo -n "Please input password :"
  42. read password

  43. case $password in
  44.     y|yes|Y|YES) echo -e "$usename login";;
  45.     n|no|N|NO) echo -e "password error";;
  46.     *) echo -e " "
  47. esac

  48. #5. math and compare
  49. #-eq 等于 -ne 不等于 -gt 大于
  50. #-lt 小于 -le 小于等于 -ge 大于等于

  51. sum=0
  52. i=0
  53. while [ $i -le 100 ]
  54. do
  55.     let sum=$sum+$i
  56.     let i=i+1
  57. done
  58. echo -e "sum=$sum"
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(709) | 评论(0) | 转发(0) |
0

上一篇:shell脚本编程

下一篇:configure 配置选项

给主人留下些什么吧!~~
评论热议
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值