shell script problem
i can't understand the if condition
this is an example but i can't understand what is th $1 $ cat > ispostive #!/bin/sh # # Script to see whether argument is positive # if test $1 -gt 0 then echo "$1 number is positive" fi plesae help me thank you |
The $1 variable refers to the first parameter passed to the script. The if statment just checks if the parameter given is greater than (-gt) 0.
BTW you may want to keep these sorts of questions in the 'newbie' or 'general' section. It is not relevant to networking. |
thank you for your help
but stil i dont know where is the first parameter |
thank you
i get it but i have another question what the diffrent between test statement and [ expr ] statement thank you very much |
The answer to all your questions can be found in the bash man pages.
Type: man bash ...at the first pause (bottom of screen -or- : ), type /expr from then on keep typing n (for next occurance) Make sure you checkout the chapters labeled: Positional Parameters ARITHMETIC EVALUATION CONDITIONAL EXPRESSIONS |
All times are GMT -5. The time now is 07:14 PM. |