標籤:
恩,就這麼開始了
首先說一下這個小小的插曲。。。寫著寫著,它就崩潰了,然後我也崩潰了。。。崩潰的我到處找一個不會讓我崩潰的工具,然後找來找去就找到了scribefire。
1. 關於從Command Line取參數進來
~ Shell Built in Variables |
~ Meaning |
$# |
Number of command line arguments. |
$? |
Exit Status |
$* |
string that contains all arguments to shell |
[email protected] |
Same as above, except when quoted. |
$- |
Option supplied to shell |
$$ |
PID of shell |
$! |
PID of last started background process (started with &) |
另外,還有$1,$2,$3...代表低N個參數。
2. 關於方括弧
這貨是一個函數!它不是符號!不是符號!它等同於test命令,那個吧,你要是不給它整個空格啥的,等著報錯吧,解譯器會告訴你找不到符號啊啊啊。
#!/bin/sh##Script to test if..elif...elseif [ $# -eq 0 ]thenecho "$0 : You must give one integers!"exit 1fiif [ $1 -gt 0 ]then echo "$1 is positive"elif [ $1 -lt 0 ]then echo "$1 is negative"elif [ $1 -eq 0 ]then echo "$1 -eq 0"else echo "Opps! $1 is not number, give number please!"fi
千萬記得`[`後面要加空格,`]`前面也要空格啊啊啊。
3.
有事先放一下:
source
http://linux.vbird.org/linux_server/0250simple_firewall.php
http://tille.garrels.be/training/bash/
http://freeos.com/guides/lsst/index.html
http://www.hlevkin.com/Shell_progr/hellobash.htm
http://www.cyberciti.biz/faq/bash-for-loop/
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.ibm.com/developerworks/linux/library/l-bash/index.html
開個帖,開始學習shell編程