Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash loop

#!/bin/bash

# A simple bash "for loop" example below...
# This loop will run 4 times, and will echo the number in sequence as it goes.
# 3 is increment size
# Mind the double . between the {}
# Note how the variable is called with the $ prefix, which can be done within the "" quotes!
for i in {1..12..3}
do
   echo "This is loop number $i"
done

# Result :
# This is loop number 1
# This is loop number 4
# This is loop number 7
# This is loop number 10
Comment

bash for loop

for i in {1..10} ; do ... ; done
Comment

loop bash

years=(2018 2019)
days=(74 274)

for year in "${years[@]}"; do
    for day in $(seq -w ${days[0]} ${days[1]}); do
               echo $year
               echo $day
    done
done
Comment

bash for loop

for ((i = 1; i <= 10 ; i++)); do
  echo $i
done
Comment

bash for loop

#!bin/bash

for i in {1..5}
do
    echo i:$i
done
Comment

bash for loop

for VARIABLE in file1 file2 file3
do
	command1 on $VARIABLE
	command2
	commandN
done
Comment

loop 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 script loop

while [ <some test> ]
do
<commands>
done
Comment

bash for loop step

for i in `seq 0 2 10`; do echo $i; done
Comment

bash for loop

for FILE in $(ls -A); do la $FILE; done
Comment

bash for in loop

for <item> in <list of items>
do
    <command to run>
done
Comment

bash code for loop

#!/bin/bash
for i in {1..5}
do
   echo "Welcome $i times"
done
Comment

PREVIOUS NEXT
Code Example
Shell :: express-generator with ejs 
Shell :: docker stop and remove specific container 
Shell :: ip config ubuntu 
Shell :: find program path linux 
Shell :: install woeusb in ubuntu 
Shell :: nmap linux 
Shell :: ping list of ip addresses powershell 
Shell :: revert to a particular commit git 
Shell :: Get total duration of video files in a directory 
Shell :: laravel: command not found 
Shell :: git command to change drive 
Shell :: bash lowercase 
Shell :: Keep CMD open after BAT file executes 
Shell :: get linux distro from terminal 
Shell :: vim open shell in current directory 
Shell :: size of a file linux 
Shell :: how to assign an ad group to a folder mac os terminal 
Shell :: ubuntu kill process 
Shell :: cannot delete branch checked out at 
Shell :: install yarn in mac 
Shell :: how to install tensorflow on anaconda 
Shell :: install babel 
Shell :: jupyter sagemath kernel 
Shell :: how to know which shell is specified for linux 
Shell :: extract tgz from ubuntu terminal 
Shell :: debian docker 
Shell :: how to find my apache server ip address 
Shell :: show seconds ubuntu 
Shell :: aws sli how to delete table 
Shell :: git get clean remote branch 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =