Hi everyone,
Can ny1 help me out regarding while loop arguments
i.e. what does
-gt
-ge
-lt
-le
means?
actually i am new to while loops
Hi everyone,
Can ny1 help me out regarding while loop arguments
i.e. what does
-gt
-ge
-lt
-le
means?
actually i am new to while loops
Simple syntax:
while command_exit_code_is_zero
do
somecmd1
somecmd2
done
-lt, -gt, ... are options of test command, look shell builtin test (= also [ ] )
After while is some command line, shell will do it, check exit code and if it's 0 = okay, then do the command lines between do and done.
while true
while cp x y
while (( i < 100 ))
while [ "$some" -lt 100 ]
while test "$some -lt 100
while [ "$some" = "1" ]
while read line
while :
...
: is command, which is builtin and give always exit 0 status ( shell's nop command), do nothing. Today also true and false are builtin commands, so those are more "readable" as :
You can break the loop using command break.
You can jump to the while line using command continue.
ex.
while read line
do
case "$line" in
"") continue ;; # next line
end*) break ;; # end this while
esac
do_some_for "$line"
done