摘要:
#!/bin/bashecho "What is your favourite OS?"select var in "Linux" "Gnu Hurd" "Free BSD" "Windows" "Other"; do break;doneecho "You have selected $var"ps :var=`date "+%Y%m%d %H%M%S"` 阅读全文
posted @ 2013-05-03 16:28
践道者
阅读(197)
评论(0)
推荐(0)
摘要:
#!/bin/bashftype="$(file "$1")"case "$ftype" in"$1: Zip archive"*) unzip "$1";;"$1: gzip compressed"*) gunzip "$1";;"$1: bzip2 compressed"*) bunzip2 "$1";;*) echo "File $1 can not be uncompressed with smar 阅读全文
posted @ 2013-05-03 16:24
践道者
阅读(274)
评论(0)
推荐(0)
摘要:
格式:if ....; then ....elif ....; then ....else ....fi[ -f "somefile" ] :判断是否是一个文件[ -x "/bin/ls" ] :判断/bin/ls是否存在并有可执行权限[ -n "$var" ] :判断$var变量是否有值[ "$a" = "$b" ] :判断$a和$b是否相等示例:#!/bin/bashif [ ${SHELL} = "/bin/bash" ]; then echo "your l 阅读全文
posted @ 2013-05-03 16:05
践道者
阅读(254)
评论(0)
推荐(0)
摘要:
var_1=2var_2=3var_res="$[$var_1+$var_2]"echo $_var_res #print 5 阅读全文
posted @ 2013-05-03 15:57
践道者
阅读(161)
评论(0)
推荐(0)
摘要:
#!/bin/bash#print hello world in the console windowa="Hello,World"echo "A is:" $a赋值符号左右两边不能有空格,否则语法错误。num=2echo "this is ${num}d"用{}将变量名括起来,起到确定变量名的作用获取命令行参数总数 $#后台执行,模拟多进程#!/bin/bashrsync .... &rsync .... &... 阅读全文
posted @ 2013-05-03 15:46
践道者
阅读(244)
评论(0)
推荐(0)