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

for loop while loop shell functions

while check1
do
    # Loop while check1 is successful (returns 0)

    if check1
    then
        echo 'check1 was successful'
    fi

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 :: error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: the remote end hung up unexpectedly 
Shell :: untrack folder git 
Shell :: git add -p 
Shell :: uninstall node 
Shell :: Test connection to Redis with netcat 
Shell :: create a file in vim 
Shell :: grep search text in folder 
Shell :: how to install gimp in ubuntu 
Shell :: bash blackeye 
Shell :: how to install atom on manjaro 
Shell :: vlc 
Shell :: doom emacs 
Shell :: git remanme folder 
Shell :: install all dependencies npm 
Shell :: git change git commit date 
Shell :: windows subsystem for linux install 
Shell :: touch in windows 
Shell :: /usr/bin/env: ‘bash ’: No such file or directory 
Shell :: bash split string into variables 
Shell :: linux umount command 
Shell :: ionic cordova sign apk 
Shell :: powershell run bat file 
Shell :: git config email 
Shell :: edit crontab daily 
Shell :: react-icons 
Shell :: bash rm all except 
Shell :: yum install tesseract-ocr 
Shell :: create strapi app 
Shell :: where to find zshrc mac 
Shell :: create jar with maven commandline 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =