Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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
 
PREVIOUS NEXT
Tagged: #bash #loop
ADD COMMENT
Topic
Name
9+1 =