-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathsession-10.txt
138 lines (102 loc) · 2.58 KB
/
session-10.txt
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
1. signup to github
2. create repo
3. clone the repo
4. create github token
5. git add . ; git commit -m "some-msg"; git push origin main
Shell Script
---------------
1st line -->#!/bin/bash
shebang is the location interpreter, commands written inside shell script is interpreted and executed by this shebang
zshell
kshell
cshell
fish
bash shell == shell
how to execute shell script
---------------------
sh <script>
bash <script>
./<script-name> --> this should have execute permission
X --> running the command/script
1. repeated words
2. if you want to change, you have to change it every where
3. while changing accidently you may change actual code
variables
------------
int i=0, j=0
i and j are variables
x=0, y=1
derive the formula, submit variables at last
variables hold some values,
4. if you change variable value, it will be automaticaly reflected everywhere it is referred
arguments/parameters
--------------------
sh variables.sh Raheem Robert
Raheem = 1st variable
Robert = 2nd variable
.
.
.
John = nth variable
confidential information
-----------------------
We want user to enter manually before execution
Data types
------------------
integer
float
decimal
string
boolean --> true/false ... 1=true, 0=false
array
arraylist
set, map
array --> list of values
if you define a variable as array, it can hold list of values...
$VARIBALE
${VARIBALE}
+, -, *, / , %
conditions
---------------
when you want to take a decission
I want to check whether a number is greater than 20 or not
first get the number
check if it is greater than 10 or not
if greater print greater
if lesser print lower
if(expression){
this statement will execute if expression is true
}
else{
this statement will execute if expression is false
}
NUMBER=5
if(!NUMBER>10){
print "print given number is greater than 10"
}
else{
print "print given number is less than 10"
}
NUMBER>10=false, !=false
false false is true
installation
---------------
if you want to install you should have super user access
so check user
if super user, proceed
if not super user, I should throw proper error
How you run a command inside shell script and take the output
if id is 0 then super user, if not 0 then normal user
if error comes, can we proceed? NO
disadvantage of shell script
------------------------
shell script will not stop even it faces the error, it is user responsibility to check the previous command is success/not
exit status
------------
what is exit status?
$? --> to check the exit status of previous command
0 --> success
other than 0 --> failure
1-127
dnf installation commands are 20..
140 lines of validation