Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash while true

while :; do
  # loop infinitely
done
Comment

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 do-while

while : ; do 
    ACTION_CODE
    [[ CONDITION_STATEMENT ]] || break
done
Comment

linux while shell

while true; do your_command; sleep5; done
Comment

PREVIOUS NEXT
Code Example
Shell :: reattach to screen 
Shell :: ft2build.h: No such file or directory fedora 
Shell :: install insomnia in ubuntu 
Shell :: git with ssh instead of https 
Shell :: vim cut 
Shell :: unzip gz file linux 
Shell :: cli edit file 
Shell :: npm install 
Shell :: change commit message git 
Shell :: vim delete to end of file 
Shell :: bash rename multiple files pattern 
Shell :: vscode publish to github organisation 
Shell :: spotify ubuntu 
Shell :: .bat script on computer startup 
Shell :: check if string starts with powershell 
Shell :: how to push cloned repo 
Shell :: push imagesto docker 
Shell :: powershell script example 
Shell :: git recover deleted file 
Shell :: split vim window 
Shell :: push branch to main github 
Shell :: opera browser for fedora 
Shell :: docker file entrypoint script shell 
Shell :: dns_probe_finished_nxdomain ubuntu 
Shell :: git newly created branch not showing 
Shell :: install gitflow 
Shell :: kivy install ubuntu 
Shell :: cor installation 
Shell :: daily bing ubuntu 
Shell :: how to add a file in git 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =