-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.sh
More file actions
41 lines (37 loc) · 726 Bytes
/
Loops.sh
File metadata and controls
41 lines (37 loc) · 726 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
#For loop
#Prints the value for specified number of times
for i in {1..10}
do
echo "Hello, World! $i"
done
#while loop
#pints the value until the condition is true
count =1
num=10
while [$count -ne $num]
do
echo "Count: $count"
((count++))
done
#until loop
#prints the value until the condition is false
count=1
num=10
until [ $count -eq $num ]
do
echo "Count: $count"
((count++))
done
#infinte loop
#Prints the value until the user stops it
while true
do
echo "This is an infinite loop. Press Ctrl+C to stop it."
sleep 2s
done
#for loop with infinite loop
#Prints the value for specified number of times and then continues to print until the user stops it
for (( ; ; ))
do
echo "Hello, World! $i"
done