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 :: find unix 
Shell :: Errors were encountered while processing: libglx-mesa0:amd64 
Shell :: adonis make migration 
Shell :: php.ini ubuntu 
Shell :: how to install sublime text arch linux 
Shell :: docker compose plugin 
Shell :: bash copy file to directory 
Shell :: python install z3 
Shell :: how to use zsh on mac 
Shell :: move files one level up linux 
Shell :: how to check the parent branch in git 
Shell :: bash script language check if item in array 
Shell :: git reset hard for remote 
Shell :: linux get full path 
Shell :: git remember credentials ubuntu 
Shell :: how to create tag in git 
Shell :: powershell writeline 
Shell :: change window name command prompt 
Shell :: how to run .run file in linux 
Shell :: auth token 
Shell :: get disk partitions linux 
Shell :: bash float division 
Shell :: uid : unable to do port forwarding: socat not found 
Shell :: dpkg install deb with dependencies 
Shell :: install vlc rhel 
Shell :: ssh copy file from local to remote 
Shell :: copy from master to branch 
Shell :: how to make a new branch git 
Shell :: git abort changes 
Shell :: how to setup dockers on aws 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =