-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5-1-loop.sh
More file actions
52 lines (46 loc) · 791 Bytes
/
5-1-loop.sh
File metadata and controls
52 lines (46 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /bin/bash
###############################################################
# While Loop (terminate when condition becomes false)
number=1
while (( $number < 10 ))
do
echo "$number"
number=$((number+1))
done
###############################################################
# Until Loop (terminate when condition becomes true)
number=1
until (( $number > 10 ))
do
echo "$number"
number=$((number+1))
done
###############################################################
# For Loop
for i in 1 2 3 4 5
do
echo $i
done
# 0 1 2 ..... 20
for i in {0..20}
do
if (( i >= 10 && i <= 15))
then
continue
fi
echo $i
done
# {starting..ending..increment}
for i in {0..20..2}
do
if (( i >= 10 ))
then
break
fi
echo $i
done
# the classical way
for (( i=0; i<5; i++))
do
echo $i
done