首页 > 其他 > 详细

shelll Test

时间:2014-04-19 15:22:40      阅读:446      评论:0      收藏:0      [点我收藏+]

 

bubuko.com,布布扣
  1 #!/bin/bash
  2 #This is a very simple example
  3 #echo "hello world"
  4 #echo "######################################"
  5 #echo " Hellow! Wellcome"
  6 #echo "######################################"
  7 #echo " Hellow!\n Wellcome"
  8 #echo "######################################"
  9 #echo -e " Hellow!\nYou Are Wellcome"
 10 #echo "######################################"
 11 #echo -e "Hellow!\tYou Are Wellcome"
 12 #echo "######################################"
 13 
 14 #对变量赋值:
 15 a="hello world"
 16 # 现在打印变量a的内容:
 17 echo "A is:"
 18 echo $a
 19 
 20 #有时候变量名很容易与其他文字混淆,比如:
 21 num=2
 22 echo "this is the $numnd"
 23 #可以使用花括号{ }来告诉shell我们要打印的是num变量
 24 num=2
 25 echo "this is the ${num}nd"
 26 
 27 #if [a="hello world"]
 28 #then
 29 #echo "Hello world"
 30 #elif [$a="hello world"]
 31 #then
 32 #echo "hello world"
 33 #else
 34 #echo "Hello every one"
 35 #fi
 36 
 37 for x in 1 2 3 4 5 
 38 do 
 39 echo "$x,"
 40 done
 41 x=1999
 42 let "x = $x + 1"
 43 echo $x
 44 x="olympic‘"$x
 45 echo $x
 46 
 47 HELLO=Hello
 48 function hello {
 49 local HELLO=World
 50 echo $HELLO
 51 }
 52 echo $HELLO
 53 hello
 54 echo $HELLO
 55 
 56 x=20
 57 if [ $x -gt 90 ]
 58 then
 59 echo "Good, ${x}"
 60 elif [ $x -gt 70 ]
 61 then
 62 echo "OK, $x"
 63 else
 64 echo "Bad, $x"
 65 fi
 66 
 67 echo "Hit a key, then hit return."
 68 read Keypress
 69 case "$Keypress" in
 70 [a-z] ) echo "Lowercase letter";;
 71 [A-Z] ) echo "Uppercase letter";;
 72 [0-9] ) echo "Digit";;
 73 * ) echo "Punctuation, whitespace, or other";;
 74 esac
 75 
 76 square() {
 77 let "res = $1 * $1"
 78 return $res
 79 }
 80 square $1
 81 result=$?
 82 echo $result
 83 
 84 a=$RANDOM
 85 echo $a
 86 
 87 echo ${var=There is an error}
 88 
 89 passwd="aka@tsinghua"
 90 ftp -n localhost <<FTPFTP
 91 user anonymous $passwd
 92 binary
 93 bye
 94 FTPFTP
 95 
 96 for ((i=1;i<10;i=$i+1));do
 97 echo "a"
 98 done
 99 
100 
101 OPTIONS="Hello Quit"
102 select opt in $OPTIONS; do
103 if [ $opt = "Quit" ]; then
104 echo done
105 exit
106 elif [ "$opt" = "Hello" ]; then
107 echo Hello World
108 else
109 clear
110 echo bad option
111 fi
112 done
113 
114 exit 0
bubuko.com,布布扣

 

shelll Test,布布扣,bubuko.com

shelll Test

原文:http://www.cnblogs.com/fly-xiang-zhao/p/3674650.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!