-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbash_crash_course.sh
106 lines (82 loc) · 1.75 KB
/
bash_crash_course.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# echo "Hello World"
# name="CodeMite"
# read -p "Enter your name:> " name
# echo "Your name is = ${name}"
################################
# CONDITIONAL STATEMENTS
################################
# read -p "Enter your age:> " age
# if (( age > 18 )); then
# echo "You are eligible to vote!"
# elif ((age == 18)); then
# echo "You are 18!"
# echo "You are eligible to vote!"
# else
# echo "You are NOT eligible to vote!"
# fi
################################
# CASE (SWITCH) STATEMENTS
################################
# read -p "Enter you choice:> " choice
# case $choice in
# 1)
# echo 'You entered 1'
# ;;
# 'code')
# echo "You entered 'code'"
# ;;
# *)
# echo "This is default"
# esac
################################
# LOOPS
################################
# i=0
# while ((i < 10)); do
# echo "Hello World ${i}"
# ((i++))
# done
# i=0
# until ((i == 10)); do
# echo "until Hello World ${i}"
# ((i++))
# done
# imgs=$(ls ./imgs)
# cd imgs
# counter=1
# for each in $imgs; do
# mv $each "$counter.png"
# ((counter++))
# done
################################
# FUNCTIONS
################################
# function foo() {
# local number_of_args=$#
# local all_args=$*
# echo "There are $number_of_args arguments passed"
# echo "The values passed are '$all_args'"
# }
# foo 1 2 3 454
# function sum() {
# # local first=$1
# # local second=$2
# # local result=$(($first + $second))
# # echo $result
# local result=0
# for number in $@; do
# result=$(($result + $number))
# done
# echo $result
# }
# result=$(sum 2 5 3 5 32)
# echo "The sum is = $result"
function heavy_printing() {
if (($1 <= 10)); then
local i=$1
echo $i
((i++))
heavy_printing $i
fi
}
heavy_printing 0