Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

while loop bash

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

PREVIOUS NEXT
Code Example
Shell :: start redis ubuntu 
Shell :: Anydesk remote server display not supported e.g Wayland 
Shell :: mac tftp server directory 
Shell :: heroku push non main branch 
Shell :: fortigate show system version 
Shell :: latte dock application launcher shortcut 
Shell :: cptable is not defined at make_xlsx 
Shell :: how to run multiple npm scripts parallel 
Shell :: how to find the changes in git 
Shell :: create github repo with curl 
Shell :: mikrotik reboot bash sintakx 
Shell :: -----Mg: *scratch* (fundamental)----All-------------------------------------------------------------------------------- 
Shell :: npm start script not found 
Shell :: httrack 
Shell :: hadoop report command 
Shell :: push local branch changes to remote branch 
Shell :: how to install rebar3 
Shell :: zsh problem: compinit:503: no such file or directory 
Shell :: how to install jupyterlab 
Shell :: Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted 
Shell :: pushing image to docker hub 
Shell :: get the latest from remote git 
Shell :: download powershell 7.2.1 
Shell :: docker container network troubleshoot 
Shell :: how to change priority in network interface ubuntu 
Shell :: docker nodejs 
Shell :: run bat file 
Shell :: vim set color scheme in vimrc 
Shell :: download chrome on ubuntu 20.04 unsupported file 
Shell :: git delete all remote branch except master 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =