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

linux while loop

while true;
do
	#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

linux while shell

while true; do your_command; sleep5; done
Comment

PREVIOUS NEXT
Code Example
Shell :: How do I create a next application 
Shell :: wget typo3 8 
Shell :: Shell Script to Install Ansible AWX on centos 7 
Shell :: create branch git command 
Shell :: linux bash assign variable and print to console 
Shell :: create a new git branch 
Shell :: adb default location 
Shell :: bash remove directory recursively locally and git 
Shell :: how to run a specific knex seed file 
Shell :: xstate install 
Shell :: regex to accept at most two digit :js 
Shell :: gatsby image 
Shell :: how to install tor on kali linux 
Shell :: curl detailed response 
Shell :: how to move wsl storage 
Shell :: shopware 6 build storefront 
Shell :: enter passphrase is asking for password 
Shell :: apache2 default page 
Shell :: convert mp4 to hap 
Shell :: windows battery report health 
Shell :: git request-pull 
Shell :: powershell command shutdown computer 
Shell :: npm audit undu 
Shell :: cli50 docs 
Shell :: uninstall g2o 
Shell :: docker tag image 
Shell :: how to check ssh agent is running in git bash 
Shell :: decrypt user password linux 
Shell :: install with pip in jupyter 
Shell :: add conda to sudo path 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =