-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.sh
executable file
·87 lines (72 loc) · 1009 Bytes
/
bash.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
#! /bin/bash
:<<COMMENT
this is practice bash set.
COMMENT
echo "Hello world!"
# var in bash `var_name=value`
first_mid=Raja\ Ram
surname=Sharma
echo $first_mid $surname
#Arithmetic
:<<COMMENT
+, -, *, /, **, %
COMMENT
#var=$((expression))
var=$((3+9))
var=$((2+5))
echo $var
#Read input
#read -p "Enter your age" var_name
read -p "Enter your age: $first_mid $surname " age
echo "age:" $age
:<<COMMENT
comparision:
1. equality -eq
2. greater than equal to -ge
3. greater than -gt
4. less than equal to -le
5. less than -lt
6. not equal to -ne
COMMENT
# condition
:<<COMMENT
if [condition]
then
commands
elif [condition]
then
commands
else
do
commands
fi
COMMENT
# looping
:<<COMMENT
for i in {1..5}
do
echo $i
done
COMMENT
#arguemnts
:<<COMMENT
$@
COMMENT
for i in $@
do
echo "Entered arguemnts: $i"
done
#function
print(){
echo "I am print"
}
print
# function arguemnts
print(){
echo "I am 2nd print"
echo "arguemnts: " $1 $2 $3
return 5
}
print 1 2 3
#return val
echo $?