get help while writting shell scripts
October 22nd, 2006 mysurface Posted in Bash, Misc, help | Hits: 6962 |
sometimes I just forgot the syntax of using if, while or for. Sometimes I am not sure the syntax i used is it correct. Let say I wanna refers back how to use square bracket ( [ ] ), by specified
man "\["
It leads me to a lengthy BASH_BINUTILS manual, which cause me more headache. I discover a good command which can help me a bit better, its call help.
help [
The result I get is
[: [ arg... ]
This is a synonym for the "test" builtin, but the last
argument must be a literal `]', to match the opening `['.
[[ ... ]]: [[ expression ]]
Returns a status of 0 or 1 depending on the evaluation of the conditional
expression EXPRESSION. Expressions are composed of the same primaries used
by the `test' builtin, and may be combined using the following operators
( EXPRESSION ) Returns the value of EXPRESSION
! EXPRESSION True if EXPRESSION is false; else false
EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false
EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false
When the `==' and `!=' operators are used, the string to the right of the
operator is used as a pattern and pattern matching is performed. The
&& and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
determine the expression's value.
Isn’t it better? If you still find it difficult, then remember to refers here : ) LBE have a category for Bash.
To get more shorter reference help, specified with -s, for example:
help -s if
This will show the result as bellow:
if: if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
Live Chat!







Leave a Reply