Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

while loop bash

while true;
do
	#code
done
Comment

shell script while loop example

#!/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
Comment

while loop shell script

#!/bin/sh

a=0

while [ $a -lt 10 ]
do
   echo $a
   a=`expr $a + 1`
done
Comment

bash while loop

#!/bin/bash
i=0
While [ $i -le 10 ]
do
 echo i:$i
 ((i+=1))
done
Comment

bash while done

while CONDITION_STATEMENT; do SOME_CODE; done
Comment

While loops in bash

#!/bin/bash
X=0
while [ $X -le 20 ]
do
	echo $X
	X=$((X+1))
done
Comment

for while bash

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
Comment

bash while

#!/bin/bash
counter=$1
factorial=1
while [ $counter -gt 0 ]
do
   factorial=$(( $factorial * $counter ))
   counter=$(( $counter - 1 ))
done
echo "$factorial"
Comment

linux while loop shell

while ! [ "${finished}" ]; do
    ...
done
Comment

linux while loop shell

finished=false
while ! $finished; do
    ...
    # At some point
    finished=true
done
Comment

linux while loop shell

while [ "$finished" != "true" ]; do
   ...
done
Comment

bash run while loop

while true; do echo -e "
new proccess"; php artisan queue:work --once; done
Comment

PREVIOUS NEXT
Code Example
Shell :: name stash 
Shell :: how to git push in jenkins pipeline 
Shell :: zip files linux 
Shell :: bash test if in interactive shell 
Shell :: installing api platform 
Shell :: how to run .bashrc from .zshrc 
Shell :: git diff between one file 
Shell :: rename file powershell 
Shell :: bash memory 
Shell :: install docker on linux debian 
Shell :: check if bash variable is undefined 
Shell :: add group docker compose 
Shell :: npm install --save-dev shortcut 
Shell :: how to reduce the size of an image in linux 
Shell :: git log files only 
Shell :: git Automatic merge failed; fix conflicts and then commit the result 
Shell :: what is gist in github 
Shell :: restart bind centos 8 
Shell :: set node role kubernetes 
Shell :: ubuntu 18.04 get public ip address 
Shell :: command line of linux os 
Shell :: sed line 
Shell :: vim quit 
Shell :: git remove file from being tracked 
Shell :: docker copy folder to container 
Shell :: node version manager 
Shell :: bash script assign array to variable 
Shell :: bash for 
Shell :: command used to install django cms 
Shell :: dockerfile env 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =