Well, that's how it started.
First of all, this little episode ... It was written, it collapsed, and then I collapsed ... Crash I looked everywhere for a tool that would not let me collapse, and then find out to find the ScribeFire.
1. Take parameters from 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 &) |
In addition, there are $1,$2,$3 ... represents a low n parameter.
2. About square brackets
This cargo is a function! It's not a sign! Not a sign! It is equivalent to the test command, that bar, if you do not give it the entire space what, wait for the error, the interpreter will tell you can not find the symbol AH ah.
#!/bin/sh# #Script to test if: Elif...elseif [$#-eq 0]thenecho "$0:you must give one integers!" Exit 1fiif [$1-gt 0]then echo "$ is positive" elif [$1-lt 0]then echo "$ is negative" elif [$1-eq 0]then< C5/>echo "$1-eq 0" Else echo "opps! $ not number, give number please! " Fi
Remember ' [' To add a space, '] ' before the space Ah ah ah.
There is a prior release:
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
Open a post and start learning shell programming