while :; do
# loop infinitely
done
while true;
do
#code
done
#!/bin/sh
INPUT_STRING=hello
while [ "$INPUT_STRING" != "bye" ]
do
echo "Please type something in (bye to quit)"
read INPUT_STRING
echo "You typed: $INPUT_STRING"
done
#!/bin/sh
a=0
while [ $a -lt 10 ]
do
echo $a
a=`expr $a + 1`
done
#!/bin/bash
i=0
While [ $i -le 10 ]
do
echo i:$i
((i+=1))
done
while CONDITION_STATEMENT; do SOME_CODE; done
#!/bin/bash
X=0
while [ $X -le 20 ]
do
echo $X
X=$((X+1))
done
Use for in bash for iterating words in a string or values in an array as:
for value in {1, 2, 3}; do echo $value; done
for value in $(cat arguments_files.txt); do [some_command]; done
And use while for iterating lines from a pipe output as:
cat arguments_file.txt | while read line; do [some_command]; done
#!/bin/bash
counter=$1
factorial=1
while [ $counter -gt 0 ]
do
factorial=$(( $factorial * $counter ))
counter=$(( $counter - 1 ))
done
echo "$factorial"
while ! [ "${finished}" ]; do
...
done
finished=false
while ! $finished; do
...
# At some point
finished=true
done
while [ "$finished" != "true" ]; do
...
done
while : ; do
ACTION_CODE
[[ CONDITION_STATEMENT ]] || break
done
while true; do echo -e "
new proccess"; php artisan queue:work --once; done