1
00:00:00,240 --> 00:00:03,600
In this lesson we're going to talk about coding in Bash.

2
00:00:03,600 --> 00:00:05,790
Now Bash is the first one we're going to cover

3
00:00:05,790 --> 00:00:09,120
because it comes installed by default inside every

4
00:00:09,120 --> 00:00:11,490
Linux distribution you're going to come across.

5
00:00:11,490 --> 00:00:14,040
Bash is a command line scripting language

6
00:00:14,040 --> 00:00:17,250
that's used for the command shell inside Unix-like systems,

7
00:00:17,250 --> 00:00:20,250
including Linux and Mac OS.

8
00:00:20,250 --> 00:00:21,690
Now if you're familiar with Linux

9
00:00:21,690 --> 00:00:24,240
and you've done some command line programming before,

10
00:00:24,240 --> 00:00:26,610
you're probably really used to using the Bash shell

11
00:00:26,610 --> 00:00:28,830
to be able to execute those commands.

12
00:00:28,830 --> 00:00:30,240
As a scripting language,

13
00:00:30,240 --> 00:00:33,240
Bash is extremely useful when you're automating tasks

14
00:00:33,240 --> 00:00:36,420
that use command line environments inside of Unix.

15
00:00:36,420 --> 00:00:38,460
If you want to be able to call things like Nmap,

16
00:00:38,460 --> 00:00:39,330
for example,

17
00:00:39,330 --> 00:00:41,760
you can do that using Bash shell scripts,

18
00:00:41,760 --> 00:00:44,010
because they already know how to interact with those

19
00:00:44,010 --> 00:00:47,430
different tools that are installed on your Linux system.

20
00:00:47,430 --> 00:00:50,160
The one big limitation when scripting in Bash

21
00:00:50,160 --> 00:00:52,770
is that it is not an object oriented language.

22
00:00:52,770 --> 00:00:55,560
So you are a little bit more limited when you're using Bash

23
00:00:55,560 --> 00:00:58,680
for scripting than you are in other languages like Python,

24
00:00:58,680 --> 00:00:59,513
Pearl,

25
00:00:59,513 --> 00:01:00,346
Ruby,

26
00:01:00,346 --> 00:01:01,179
PowerShell,

27
00:01:01,179 --> 00:01:02,400
or JavaScript.

28
00:01:02,400 --> 00:01:05,910
Now in this lesson we're going to go through some basic Bash,

29
00:01:05,910 --> 00:01:08,640
syntax and commands that you may come across

30
00:01:08,640 --> 00:01:11,040
as you're working with Bash scripts.

31
00:01:11,040 --> 00:01:11,873
First,

32
00:01:11,873 --> 00:01:14,340
anytime you start looking at a Bash script,

33
00:01:14,340 --> 00:01:16,740
it should always start out with the same line.

34
00:01:16,740 --> 00:01:21,740
And this is hashtag bang slash bin slash bash.

35
00:01:21,750 --> 00:01:24,390
This means you're going to see that hashtag,

36
00:01:24,390 --> 00:01:26,760
which normally signifies a comment line

37
00:01:26,760 --> 00:01:29,310
and then the bang or exclamation mark,

38
00:01:29,310 --> 00:01:31,560
then slash bin slash bash,

39
00:01:31,560 --> 00:01:33,720
which says this is a Bash script

40
00:01:33,720 --> 00:01:36,750
and it should be executed using the Bash shell.

41
00:01:36,750 --> 00:01:39,630
From there you're then going to have whatever else you want

42
00:01:39,630 --> 00:01:43,140
coded into that script for what you want to do.

43
00:01:43,140 --> 00:01:44,850
Now if you're looking at a script

44
00:01:44,850 --> 00:01:46,770
and you're trying to figure out if it's a Bash script,

45
00:01:46,770 --> 00:01:48,480
what's the first thing you should look at?

46
00:01:48,480 --> 00:01:49,313
That's right,

47
00:01:49,313 --> 00:01:51,030
you should look at the first line.

48
00:01:51,030 --> 00:01:55,080
If it has hashtag bang slash bin slash bash,

49
00:01:55,080 --> 00:01:56,772
you know it's a Bash script.

50
00:01:56,772 --> 00:02:00,210
Now any other time you see that hashtag

51
00:02:00,210 --> 00:02:02,910
you should remember that this is a comment.

52
00:02:02,910 --> 00:02:06,150
Now this holds true in many different programming languages,

53
00:02:06,150 --> 00:02:06,983
Bash,

54
00:02:06,983 --> 00:02:07,816
Python,

55
00:02:07,816 --> 00:02:08,649
Ruby,

56
00:02:08,649 --> 00:02:11,610
and PowerShell all use the syntax of a hashtag

57
00:02:11,610 --> 00:02:14,010
to signify everything beyond that hashtag

58
00:02:14,010 --> 00:02:17,310
is going to be ignored by the scripting engine or compiler

59
00:02:17,310 --> 00:02:19,830
because it's just a human readable comment.

60
00:02:19,830 --> 00:02:21,690
So I might say,

61
00:02:21,690 --> 00:02:22,710
hashtag,

62
00:02:22,710 --> 00:02:24,810
this is the first line of my script.

63
00:02:24,810 --> 00:02:26,400
And that just tells people that that's

64
00:02:26,400 --> 00:02:27,990
the first line of my script,

65
00:02:27,990 --> 00:02:31,140
or I might tell them exactly what this script is used for.

66
00:02:31,140 --> 00:02:34,530
Maybe it's hashtag this script is used to do backups

67
00:02:34,530 --> 00:02:35,790
of my systems.

68
00:02:35,790 --> 00:02:37,470
Something like that.

69
00:02:37,470 --> 00:02:39,870
The next thing we need to talk about inside of Bash

70
00:02:39,870 --> 00:02:41,760
is the idea of variables.

71
00:02:41,760 --> 00:02:43,980
Now we've talked generally about variables before

72
00:02:43,980 --> 00:02:45,897
and how they're used to represent any value

73
00:02:45,897 --> 00:02:48,090
and that they can be changed during the execution

74
00:02:48,090 --> 00:02:49,470
of the program.

75
00:02:49,470 --> 00:02:53,430
For Bash you can declare a variable by using the variable

76
00:02:53,430 --> 00:02:56,850
name equals and the thing you want it to be.

77
00:02:56,850 --> 00:02:57,780
For example,

78
00:02:57,780 --> 00:03:00,960
if I did customer name equals Jason,

79
00:03:00,960 --> 00:03:04,500
that would now define that variable customer name

80
00:03:04,500 --> 00:03:05,850
as a variable.

81
00:03:05,850 --> 00:03:08,500
Now anytime I want to call that customer name variable,

82
00:03:08,500 --> 00:03:10,560
I'm not going to write customer name,

83
00:03:10,560 --> 00:03:14,040
instead I'm going to use dollar sign customer name

84
00:03:14,040 --> 00:03:15,608
and the dollar sign customer name says,

85
00:03:15,608 --> 00:03:19,410
I want to call the variable known as customer name.

86
00:03:19,410 --> 00:03:21,000
So when you're assigning something,

87
00:03:21,000 --> 00:03:22,380
there's no dollar sign.

88
00:03:22,380 --> 00:03:23,370
When you're calling it,

89
00:03:23,370 --> 00:03:25,110
there is a dollar sign.

90
00:03:25,110 --> 00:03:27,210
Also notice that I use a syntax

91
00:03:27,210 --> 00:03:29,700
of uppercase and lowercase letters here,

92
00:03:29,700 --> 00:03:32,910
generally in Bash and a lot of our other naming schemes,

93
00:03:32,910 --> 00:03:36,000
we will call things as variables using title case

94
00:03:36,000 --> 00:03:37,830
where the first letter is capitalized

95
00:03:37,830 --> 00:03:39,870
and the rest of the word is lowercase.

96
00:03:39,870 --> 00:03:41,280
This just makes it easier to read

97
00:03:41,280 --> 00:03:43,050
when I have double name words,

98
00:03:43,050 --> 00:03:44,160
like customer name,

99
00:03:44,160 --> 00:03:46,650
being used as a single variable.

100
00:03:46,650 --> 00:03:48,930
In Bash when you declare your variable,

101
00:03:48,930 --> 00:03:51,240
you can also type that variable.

102
00:03:51,240 --> 00:03:53,850
Now typing is where you declare a specific function

103
00:03:53,850 --> 00:03:55,470
essentially for that variable.

104
00:03:55,470 --> 00:03:56,700
Is it going to be a string,

105
00:03:56,700 --> 00:03:57,810
a numeric array,

106
00:03:57,810 --> 00:03:58,643
a number,

107
00:03:58,643 --> 00:04:00,060
or something like that.

108
00:04:00,060 --> 00:04:01,590
Essentially to do this,

109
00:04:01,590 --> 00:04:04,830
you're going to do declare option the variable name

110
00:04:04,830 --> 00:04:06,450
equals the value.

111
00:04:06,450 --> 00:04:07,440
So for example,

112
00:04:07,440 --> 00:04:10,230
if I wanted to create a variable called phone number

113
00:04:10,230 --> 00:04:12,480
and I wanted it to be treated as a number,

114
00:04:12,480 --> 00:04:13,920
I can declare it by saying,

115
00:04:13,920 --> 00:04:18,660
declare dash I then phone number equals

116
00:04:18,660 --> 00:04:22,620
and whatever value I want like 1, 1, 1, 1, 1, 1, 1.

117
00:04:22,620 --> 00:04:24,660
This is now my seven digit phone number

118
00:04:24,660 --> 00:04:27,030
and it will be treated as a number.

119
00:04:27,030 --> 00:04:29,070
Now if you want to make something a constant

120
00:04:29,070 --> 00:04:30,510
where it's not going to change,

121
00:04:30,510 --> 00:04:32,460
such as the definition of Pi,

122
00:04:32,460 --> 00:04:35,310
we can do that by again using the declare option.

123
00:04:35,310 --> 00:04:40,310
We're going to do declare dash r Pi equals 3.14.

124
00:04:41,340 --> 00:04:42,330
In this case,

125
00:04:42,330 --> 00:04:44,520
I made that variable read only,

126
00:04:44,520 --> 00:04:45,353
or in other words,

127
00:04:45,353 --> 00:04:48,720
it became a constant because I can't change it again.

128
00:04:48,720 --> 00:04:51,660
The next thing we need to understand is how to use arrays

129
00:04:51,660 --> 00:04:53,280
inside of Bash.

130
00:04:53,280 --> 00:04:55,440
Now if I want to create an array in Bash,

131
00:04:55,440 --> 00:04:58,440
I'm simply going to give it a name like I would a variable.

132
00:04:58,440 --> 00:05:02,370
So I might use something like tempArray equals

133
00:05:02,370 --> 00:05:04,980
and then I want to put all of the things it's going to equal

134
00:05:04,980 --> 00:05:07,800
inside of parenthesis and separate it by commas.

135
00:05:07,800 --> 00:05:12,800
So tempArray equals parenthesis value1 comma value two

136
00:05:12,810 --> 00:05:14,550
comma value three.

137
00:05:14,550 --> 00:05:17,400
Now I have an array with three different items in it

138
00:05:17,400 --> 00:05:20,640
listed as value one, two, and three.

139
00:05:20,640 --> 00:05:22,590
If you want to get information stored in an array

140
00:05:22,590 --> 00:05:24,270
back out inside of Bash,

141
00:05:24,270 --> 00:05:27,030
you're simply going to refer to it as dollar sign,

142
00:05:27,030 --> 00:05:27,900
the array,

143
00:05:27,900 --> 00:05:29,850
bracket and the position number.

144
00:05:29,850 --> 00:05:33,570
So in the case of my temporary array with my three values,

145
00:05:33,570 --> 00:05:35,209
if I wanted to pull out value two,

146
00:05:35,209 --> 00:05:37,050
I would use dollar sign,

147
00:05:37,050 --> 00:05:40,536
tempArray bracket one end bracket.

148
00:05:40,536 --> 00:05:42,870
This would then be able to give me the value

149
00:05:42,870 --> 00:05:46,350
from position number two because we count from zero,

150
00:05:46,350 --> 00:05:47,183
then one,

151
00:05:47,183 --> 00:05:49,020
then two inside of computers,

152
00:05:49,020 --> 00:05:51,390
and that would give me value two back as the thing

153
00:05:51,390 --> 00:05:52,980
I'm referencing.

154
00:05:52,980 --> 00:05:56,610
Next we have named arrays and associative arrays.

155
00:05:56,610 --> 00:05:59,790
this almost like a table inside of a database.

156
00:05:59,790 --> 00:06:01,710
And any data stored in this array

157
00:06:01,710 --> 00:06:03,336
is now going to be based on names.

158
00:06:03,336 --> 00:06:06,994
So in Bash I do this by having to declare the array,

159
00:06:06,994 --> 00:06:08,637
using a specific type.

160
00:06:08,637 --> 00:06:11,670
And that type is dash capital A.

161
00:06:11,670 --> 00:06:13,560
Let's go ahead and declare a named array

162
00:06:13,560 --> 00:06:16,230
or associative array inside of Bash.

163
00:06:16,230 --> 00:06:19,770
To do this I'm going to use declare dash capital A

164
00:06:19,770 --> 00:06:21,030
and then the array name,

165
00:06:21,030 --> 00:06:21,863
in my case,

166
00:06:21,863 --> 00:06:23,664
I'm going to call it phone book.

167
00:06:23,664 --> 00:06:27,030
Now when I want to get information into that

168
00:06:27,030 --> 00:06:29,976
I'm simply going to go ahead and say phone book bracket,

169
00:06:29,976 --> 00:06:31,920
and the key I want to use,

170
00:06:31,920 --> 00:06:32,837
let's say name.

171
00:06:32,837 --> 00:06:36,240
Then I'm going to equal that to the name I want to store

172
00:06:36,240 --> 00:06:38,040
such as Jason.

173
00:06:38,040 --> 00:06:40,410
Then if I want to put additional information in there,

174
00:06:40,410 --> 00:06:42,840
I can simply do something like phone book,

175
00:06:42,840 --> 00:06:45,720
bracket number equals,

176
00:06:45,720 --> 00:06:49,380
then the number 111 dash 1111.

177
00:06:49,380 --> 00:06:51,888
Now if I want to get information back out of this array,

178
00:06:51,888 --> 00:06:56,700
I can do it by doing dollar sign curly brace phone book

179
00:06:56,700 --> 00:07:00,180
bracket name bracket curly brace,

180
00:07:00,180 --> 00:07:02,190
and this will then give me the information back out,

181
00:07:02,190 --> 00:07:04,980
such as the name which was Jason.

182
00:07:04,980 --> 00:07:07,020
If I wanted to get the phone number back out,

183
00:07:07,020 --> 00:07:10,653
I would simply use dollar sign curly bracket hone book,

184
00:07:11,726 --> 00:07:13,743
bracket number bracket curly brace,

185
00:07:14,640 --> 00:07:18,480
and then number will come back out as 111 dash 1111,

186
00:07:18,480 --> 00:07:20,760
which was the phone number I stored in there.

187
00:07:20,760 --> 00:07:23,460
This essentially is storing these key value pairs

188
00:07:23,460 --> 00:07:25,260
inside of the array for us.

189
00:07:25,260 --> 00:07:28,713
And this is a way that we can use these associative arrays.

190
00:07:29,640 --> 00:07:33,840
Next let's talk about doing comparisons inside of Bash.

191
00:07:33,840 --> 00:07:36,420
Flow controls are going to be based on doing some kind of a

192
00:07:36,420 --> 00:07:39,660
comparison like is something equal or not equal

193
00:07:39,660 --> 00:07:40,620
or greater than,

194
00:07:40,620 --> 00:07:42,210
or greater than or equal to,

195
00:07:42,210 --> 00:07:43,043
less than,

196
00:07:43,043 --> 00:07:44,160
less than or equal to,

197
00:07:44,160 --> 00:07:45,690
and things like that.

198
00:07:45,690 --> 00:07:49,290
Now when we're doing arithmetic comparisons inside of Bash,

199
00:07:49,290 --> 00:07:51,370
we're normally going to use text to signify that

200
00:07:51,370 --> 00:07:54,270
instead of actually using the symbols.

201
00:07:54,270 --> 00:07:55,260
For example,

202
00:07:55,260 --> 00:07:58,590
if I wanted to compare two variables known as A and B,

203
00:07:58,590 --> 00:08:03,420
I can do that by doing if bracket quote dollar sign a

204
00:08:03,420 --> 00:08:08,420
quote dash eq quote dollar sign b quote bracket.

205
00:08:09,180 --> 00:08:11,610
This says is a equal to b.

206
00:08:11,610 --> 00:08:12,443
If it is,

207
00:08:12,443 --> 00:08:13,980
it returns a value of one.

208
00:08:13,980 --> 00:08:14,813
If it's not,

209
00:08:14,813 --> 00:08:16,920
it returns a value of zero.

210
00:08:16,920 --> 00:08:19,770
Now if I wanted to check if two things are not equal,

211
00:08:19,770 --> 00:08:22,290
I can do that by using dash ne.

212
00:08:22,290 --> 00:08:27,030
So it would be if dollar sign a dash ne dollar sign b,

213
00:08:27,030 --> 00:08:30,330
that's going to check is a not equal to b.

214
00:08:30,330 --> 00:08:31,680
So if a and b are equal,

215
00:08:31,680 --> 00:08:33,330
I will get a zero.

216
00:08:33,330 --> 00:08:34,380
If they're not equal,

217
00:08:34,380 --> 00:08:35,580
I'll get a one because this

218
00:08:35,580 --> 00:08:38,100
is basically reverse bullion logic.

219
00:08:38,100 --> 00:08:40,740
If I want to do something as greater than something else

220
00:08:40,740 --> 00:08:43,049
I'm going to use dash gt.

221
00:08:43,049 --> 00:08:44,670
If I want to say is something greater

222
00:08:44,670 --> 00:08:48,960
than or equal to something else I'm going to use dash ge.

223
00:08:48,960 --> 00:08:51,870
If I want less than I'm going to use dash lt.

224
00:08:51,870 --> 00:08:54,690
And if I want to use less than or equal to,

225
00:08:54,690 --> 00:08:56,103
I'm going to use dash le.

226
00:08:57,210 --> 00:08:58,650
Now in addition to this,

227
00:08:58,650 --> 00:09:00,030
in newer versions of Bash,

228
00:09:00,030 --> 00:09:02,400
you can use the arithmetic symbols

229
00:09:02,400 --> 00:09:03,750
such as the less than sign,

230
00:09:03,750 --> 00:09:05,190
the less than equal to,

231
00:09:05,190 --> 00:09:06,023
the greater than,

232
00:09:06,023 --> 00:09:07,890
and the greater than equal to sign.

233
00:09:07,890 --> 00:09:09,810
But when you do that,

234
00:09:09,810 --> 00:09:11,880
you need to use double parentheses

235
00:09:11,880 --> 00:09:13,680
around the thing you're testing.

236
00:09:13,680 --> 00:09:15,300
So instead of saying,

237
00:09:15,300 --> 00:09:20,300
if bracket dollar sign a dash le dollar sign b bracket,

238
00:09:20,820 --> 00:09:24,120
we would then use parenthesis parenthesis dollar sign a

239
00:09:24,120 --> 00:09:27,510
less than dollar sign b parenthesis parenthesis.

240
00:09:27,510 --> 00:09:30,204
This double parenthesis replaces the word if

241
00:09:30,204 --> 00:09:33,960
and those brackets inside of the comparisons.

242
00:09:33,960 --> 00:09:36,810
In addition to being able to compare mathematical things,

243
00:09:36,810 --> 00:09:40,230
we also sometimes need to do comparisons with strings.

244
00:09:40,230 --> 00:09:41,160
For example,

245
00:09:41,160 --> 00:09:42,990
are two strings equal?

246
00:09:42,990 --> 00:09:46,680
Well we can do that if we use the if command.

247
00:09:46,680 --> 00:09:47,513
So again,

248
00:09:47,513 --> 00:09:50,340
we're going to use if bracket dollar sign a

249
00:09:50,340 --> 00:09:52,530
equals dollar sign b bracket.

250
00:09:52,530 --> 00:09:55,710
Notice when we were doing mathematical comparisons,

251
00:09:55,710 --> 00:09:58,315
we were using the dash eq in this format,

252
00:09:58,315 --> 00:10:01,230
but now because we're using the equal sign,

253
00:10:01,230 --> 00:10:04,080
we're doing this as a text string comparison.

254
00:10:04,080 --> 00:10:06,300
This would test something like the word Jason

255
00:10:06,300 --> 00:10:07,770
against the word Jason.

256
00:10:07,770 --> 00:10:10,464
If one had a capital letter and one had a lower case letter,

257
00:10:10,464 --> 00:10:13,050
those two words are not going to be equal,

258
00:10:13,050 --> 00:10:15,900
and we're going to get a zero return by this function.

259
00:10:15,900 --> 00:10:18,060
Now in addition to using a single equal,

260
00:10:18,060 --> 00:10:20,430
you can also use a double equal sign,

261
00:10:20,430 --> 00:10:21,570
and these are equivalent

262
00:10:21,570 --> 00:10:22,950
and it doesn't really make a difference

263
00:10:22,950 --> 00:10:25,440
when you're doing a string comparison.

264
00:10:25,440 --> 00:10:28,380
Now the next thing we have is the not equal to.

265
00:10:28,380 --> 00:10:29,940
If you want to compare two strings

266
00:10:29,940 --> 00:10:32,130
and see if they are not equal to each other,

267
00:10:32,130 --> 00:10:34,380
you can do this by comparing them using

268
00:10:34,380 --> 00:10:39,380
if bracket dollar sign a bang equals dollar sign b bracket,

269
00:10:40,650 --> 00:10:44,130
essentially we are going to use an exclamation equal sign

270
00:10:44,130 --> 00:10:46,445
to mean not equal to.

271
00:10:46,445 --> 00:10:49,530
Next we have the less than and greater than.

272
00:10:49,530 --> 00:10:50,363
And again,

273
00:10:50,363 --> 00:10:54,060
we can compare string text using less than or greater than.

274
00:10:54,060 --> 00:10:56,730
Now you may wonder how do you compare two things

275
00:10:56,730 --> 00:10:57,930
that are words?

276
00:10:57,930 --> 00:11:00,510
Well we do it based on ASCII order.

277
00:11:00,510 --> 00:11:01,440
For example,

278
00:11:01,440 --> 00:11:04,120
if I compare the word Jason to the word Dion,

279
00:11:04,120 --> 00:11:07,890
Jason is greater than Dion because J comes after D

280
00:11:07,890 --> 00:11:09,900
in the ASCII alphabet.

281
00:11:09,900 --> 00:11:14,010
To use these you're going to do if bracket dollar sign a

282
00:11:14,010 --> 00:11:16,884
slash less than dollar sign b bracket.

283
00:11:16,884 --> 00:11:19,860
Notice I had to have that slash there.

284
00:11:19,860 --> 00:11:21,450
This is an escape character

285
00:11:21,450 --> 00:11:23,880
because we are inside a single bracket.

286
00:11:23,880 --> 00:11:26,100
If I didn't want to use that escape character,

287
00:11:26,100 --> 00:11:30,150
I can type it out as if bracket bracket dollar sign a

288
00:11:30,150 --> 00:11:33,570
less than dollar sign b bracket bracket instead,

289
00:11:33,570 --> 00:11:36,600
and that way I don't need to use the escape character.

290
00:11:36,600 --> 00:11:39,870
This same format is also used for the greater than sign,

291
00:11:39,870 --> 00:11:41,580
where you're going to use double brackets

292
00:11:41,580 --> 00:11:44,070
with just the greater than sign or single brackets

293
00:11:44,070 --> 00:11:46,170
and the slash and the greater than sign

294
00:11:46,170 --> 00:11:49,143
when comparing two ASCII strings against each other.

295
00:11:50,070 --> 00:11:53,460
Next we have our logical comparisons inside of Bash.

296
00:11:53,460 --> 00:11:56,880
The most basic form of this is an if then statement.

297
00:11:56,880 --> 00:11:58,980
Inside of Bash you're going to do if,

298
00:11:58,980 --> 00:12:00,510
the condition you're testing,

299
00:12:00,510 --> 00:12:02,156
then the command you want to run,

300
00:12:02,156 --> 00:12:05,070
and then you're going to close it out using fi.

301
00:12:05,070 --> 00:12:07,440
This takes the place of using any kind of brackets

302
00:12:07,440 --> 00:12:10,590
or parentheses inside of these function calls.

303
00:12:10,590 --> 00:12:13,020
Now if you want to do something a little bit more complex,

304
00:12:13,020 --> 00:12:18,020
you can use something like if then elif then else fi.

305
00:12:19,410 --> 00:12:22,410
Now what this means is I'm going to test a first condition,

306
00:12:22,410 --> 00:12:24,240
then do some code if it's true.

307
00:12:24,240 --> 00:12:25,260
If it's not true,

308
00:12:25,260 --> 00:12:27,450
I'm going to go into a second else condition.

309
00:12:27,450 --> 00:12:28,920
I'm going to test that condition.

310
00:12:28,920 --> 00:12:29,970
If it's true,

311
00:12:29,970 --> 00:12:31,020
I'm going to do some code.

312
00:12:31,020 --> 00:12:31,950
If it's not,

313
00:12:31,950 --> 00:12:34,260
then I'm going to do the third option.

314
00:12:34,260 --> 00:12:36,810
Now the next thing we have is our loops

315
00:12:36,810 --> 00:12:39,360
and we call these our four our do while

316
00:12:39,360 --> 00:12:40,560
and our wild commands.

317
00:12:40,560 --> 00:12:42,540
We went through the different flow control options

318
00:12:42,540 --> 00:12:44,010
in an earlier lesson.

319
00:12:44,010 --> 00:12:47,640
Now in Bash we actually term them a little bit different.

320
00:12:47,640 --> 00:12:49,620
When we talk about the four loop,

321
00:12:49,620 --> 00:12:52,710
we are really talking about a four do done,

322
00:12:52,710 --> 00:12:55,290
and that's the statement syntax we're going to use.

323
00:12:55,290 --> 00:12:57,540
When you use a four do done,

324
00:12:57,540 --> 00:12:59,190
you're going to perform a set of commands

325
00:12:59,190 --> 00:13:01,410
for each item in a given list.

326
00:13:01,410 --> 00:13:06,000
This is going to take the form of four variable in list

327
00:13:06,000 --> 00:13:08,670
do some commands done.

328
00:13:08,670 --> 00:13:09,870
So for example,

329
00:13:09,870 --> 00:13:14,250
for value in curly brackets one dot dot five

330
00:13:14,250 --> 00:13:18,300
end curly brackets do echo dollar sign value

331
00:13:18,300 --> 00:13:21,000
done echo all done.

332
00:13:21,000 --> 00:13:23,490
This script is basically going to do counting.

333
00:13:23,490 --> 00:13:26,580
It's going to start out and set the value to one,

334
00:13:26,580 --> 00:13:30,000
and then it's going to echo value of one to the screen.

335
00:13:30,000 --> 00:13:32,940
Next it's going to set it to two and echo that to the screen.

336
00:13:32,940 --> 00:13:33,773
Then three,

337
00:13:33,773 --> 00:13:34,606
then four,

338
00:13:34,606 --> 00:13:35,670
then five.

339
00:13:35,670 --> 00:13:37,200
Once all five are done,

340
00:13:37,200 --> 00:13:39,180
it's then going to go to the final echo command

341
00:13:39,180 --> 00:13:40,650
and say all done.

342
00:13:40,650 --> 00:13:45,510
So what you'll see on the screen is 12345all done.

343
00:13:45,510 --> 00:13:48,720
The second one we have is what's known as a do while.

344
00:13:48,720 --> 00:13:51,570
Now a do while inside a Bash is instead

345
00:13:51,570 --> 00:13:53,940
called a wild do done.

346
00:13:53,940 --> 00:13:57,300
This performs a set of commands while a test is true.

347
00:13:57,300 --> 00:13:58,380
So it's going to take the form

348
00:13:58,380 --> 00:14:02,760
of while some test do some commands done.

349
00:14:02,760 --> 00:14:04,800
Consider the following sample script,

350
00:14:04,800 --> 00:14:08,550
counter equals one while compare the counter variable

351
00:14:08,550 --> 00:14:13,550
less than 10 do echo counter then counter plus plus

352
00:14:14,370 --> 00:14:16,920
done echo all done.

353
00:14:16,920 --> 00:14:17,904
So what is this doing?

354
00:14:17,904 --> 00:14:20,940
Well we're going to start out by setting the counter to one.

355
00:14:20,940 --> 00:14:24,257
Then as long as the variable of counter is less than 10,

356
00:14:24,257 --> 00:14:26,310
we are going to go through this loop.

357
00:14:26,310 --> 00:14:27,143
In this case,

358
00:14:27,143 --> 00:14:28,650
we just set the variable to one,

359
00:14:28,650 --> 00:14:30,540
so one is less than 10.

360
00:14:30,540 --> 00:14:32,940
So we are going to do the echo

361
00:14:32,940 --> 00:14:34,470
or printing something to the screen,

362
00:14:34,470 --> 00:14:35,670
which is the counter.

363
00:14:35,670 --> 00:14:37,380
So we print one to the screen.

364
00:14:37,380 --> 00:14:40,533
Then counter plus plus means take the value of counter,

365
00:14:40,533 --> 00:14:43,740
add one and save it back to the counter variable.

366
00:14:43,740 --> 00:14:45,690
So now my counter is two.

367
00:14:45,690 --> 00:14:46,980
Is two less than 10?

368
00:14:46,980 --> 00:14:47,880
Yes it is.

369
00:14:47,880 --> 00:14:49,200
So we'll print that to the screen.

370
00:14:49,200 --> 00:14:50,520
We'll increment the three.

371
00:14:50,520 --> 00:14:53,310
We'll continue doing that all the way through as we go

372
00:14:53,310 --> 00:14:56,040
through nine it's less than 10 we'll print nine to the

373
00:14:56,040 --> 00:14:58,113
screen we'll increment and now we're at 10.

374
00:14:58,113 --> 00:14:59,670
When we check that,

375
00:14:59,670 --> 00:15:01,350
10 is not less than 10,

376
00:15:01,350 --> 00:15:02,340
so we'll stop.

377
00:15:02,340 --> 00:15:04,110
So what you'll see is a counter.

378
00:15:04,110 --> 00:15:09,110
That's going to print 123456789All done to your screen.

379
00:15:10,290 --> 00:15:12,120
The final one we have in Bash

380
00:15:12,120 --> 00:15:14,100
is going to be the wild command.

381
00:15:14,100 --> 00:15:18,270
And in Bash we actually call this until do done.

382
00:15:18,270 --> 00:15:22,320
This performs a set of commands until a test returns true.

383
00:15:22,320 --> 00:15:27,320
So we'll do until some test do these commands done.

384
00:15:28,350 --> 00:15:29,340
For example,

385
00:15:29,340 --> 00:15:33,060
counter equals one until counter is greater than five

386
00:15:33,060 --> 00:15:38,060
do echo counter counter plus plus done echo all done.

387
00:15:38,076 --> 00:15:41,010
This says we're going to set our counter at one

388
00:15:41,010 --> 00:15:42,990
until the counter is greater than five,

389
00:15:42,990 --> 00:15:44,700
we're going to do everything in the loop.

390
00:15:44,700 --> 00:15:45,840
Since our counter is one,

391
00:15:45,840 --> 00:15:48,210
we're going to echo that counter to the screen.

392
00:15:48,210 --> 00:15:51,090
Then we're going to increment the counter and make it two.

393
00:15:51,090 --> 00:15:52,530
Is two greater than five?

394
00:15:52,530 --> 00:15:53,363
No.

395
00:15:53,363 --> 00:15:54,870
So we're going to keep doing that function.

396
00:15:54,870 --> 00:15:56,190
Echo two to the screen,

397
00:15:56,190 --> 00:15:58,470
make it three is three greater than five?

398
00:15:58,470 --> 00:15:59,303
No.

399
00:15:59,303 --> 00:16:00,330
Print that to the screen.

400
00:16:00,330 --> 00:16:01,590
Is four greater than five?

401
00:16:01,590 --> 00:16:02,423
No.

402
00:16:02,423 --> 00:16:03,270
Print that to the screen.

403
00:16:03,270 --> 00:16:04,560
Is five greater than five?

404
00:16:04,560 --> 00:16:05,393
No.

405
00:16:05,393 --> 00:16:06,450
So print that to the screen.

406
00:16:06,450 --> 00:16:08,100
And then is six now greater than five?

407
00:16:08,100 --> 00:16:08,933
Yes.

408
00:16:08,933 --> 00:16:10,710
We can stop doing that function.

409
00:16:10,710 --> 00:16:13,650
This is the way flow control works inside a Bash

410
00:16:13,650 --> 00:16:16,680
when you're using these different types of controls.

411
00:16:16,680 --> 00:16:20,160
Next we need to talk about some basic string operations.

412
00:16:20,160 --> 00:16:22,320
String operations are the commands that are used

413
00:16:22,320 --> 00:16:25,050
to manipulate data that is of the string format,

414
00:16:25,050 --> 00:16:26,533
things like words.

415
00:16:26,533 --> 00:16:28,590
Now when you're dealing with strings,

416
00:16:28,590 --> 00:16:31,500
you're going to have a variable like test string equals

417
00:16:31,500 --> 00:16:33,810
quote test space string.

418
00:16:33,810 --> 00:16:36,345
That means that variable of test string now contains

419
00:16:36,345 --> 00:16:39,377
the words test space and string.

420
00:16:39,377 --> 00:16:42,420
Now that I have that string stored as test string,

421
00:16:42,420 --> 00:16:44,370
I can display it in multiple ways

422
00:16:44,370 --> 00:16:46,800
by manipulating what is going to be displayed.

423
00:16:46,800 --> 00:16:50,040
If I use the echo command and use dollar sign test string,

424
00:16:50,040 --> 00:16:52,050
it's just going to show me the entire thing,

425
00:16:52,050 --> 00:16:54,030
test space string,

426
00:16:54,030 --> 00:16:57,810
but I can also manipulate that string before displaying it.

427
00:16:57,810 --> 00:16:59,880
Now if I wanted to show a sub string,

428
00:16:59,880 --> 00:17:02,730
I can do that by using positioning inside

429
00:17:02,730 --> 00:17:04,170
of calling that variable.

430
00:17:04,170 --> 00:17:07,710
So let's say I did echo dollar sign curly bracket

431
00:17:07,710 --> 00:17:12,710
test string colon 2 colon 4 end curly bracket.

432
00:17:12,720 --> 00:17:14,130
What does this say?

433
00:17:14,130 --> 00:17:17,430
Well this is saying that I want to start at position two

434
00:17:17,430 --> 00:17:20,010
and I want to count four places from there.

435
00:17:20,010 --> 00:17:24,000
So in my case of using the test string as my variable

436
00:17:24,000 --> 00:17:27,150
with the contents of test space string as my string,

437
00:17:27,150 --> 00:17:29,700
I can now have starting at position two,

438
00:17:29,700 --> 00:17:30,900
which is the S,

439
00:17:30,900 --> 00:17:32,430
I'm going to count four places.

440
00:17:32,430 --> 00:17:35,610
So st space S,

441
00:17:35,610 --> 00:17:37,500
that is what I'm going to show on the screen

442
00:17:37,500 --> 00:17:39,900
when I use this echo command.

443
00:17:39,900 --> 00:17:42,540
There are lots of other ways to do string operations,

444
00:17:42,540 --> 00:17:44,490
and we're just touching the surface here,

445
00:17:44,490 --> 00:17:46,260
but I just wanted to introduce you to the concept

446
00:17:46,260 --> 00:17:47,938
that what you have stored in a variable

447
00:17:47,938 --> 00:17:50,400
can be modified when you display it

448
00:17:50,400 --> 00:17:53,640
or modified and stored back into the variable.

449
00:17:53,640 --> 00:17:55,820
The next thing we need to talk about in terms of Bash

450
00:17:55,820 --> 00:17:58,290
is going to be inputting and outputting data.

451
00:17:58,290 --> 00:18:00,210
You want to take input from the keyboard,

452
00:18:00,210 --> 00:18:01,200
from your user,

453
00:18:01,200 --> 00:18:03,060
and give output back to the monitor

454
00:18:03,060 --> 00:18:04,860
when you want to give them information.

455
00:18:04,860 --> 00:18:07,800
I've already used echo many times in this demonstration,

456
00:18:07,800 --> 00:18:09,150
but echo is the easiest way

457
00:18:09,150 --> 00:18:11,220
to send things back to the monitor.

458
00:18:11,220 --> 00:18:13,243
You simply use echo and the variable

459
00:18:13,243 --> 00:18:17,160
or echo and a quote with whatever string you want to display.

460
00:18:17,160 --> 00:18:18,090
For example,

461
00:18:18,090 --> 00:18:19,365
let's say I wanted to say,

462
00:18:19,365 --> 00:18:22,020
please enter your name on the screen.

463
00:18:22,020 --> 00:18:24,701
So I would do echo quote please enter your name

464
00:18:24,701 --> 00:18:26,820
colon end quote.

465
00:18:26,820 --> 00:18:29,550
That's going to display that string on the screen.

466
00:18:29,550 --> 00:18:31,980
Now if I wanted to read information from you,

467
00:18:31,980 --> 00:18:33,630
I can use the command read

468
00:18:33,630 --> 00:18:36,660
and a variable name such as username.

469
00:18:36,660 --> 00:18:39,240
Now when you enter in your username and hit enter,

470
00:18:39,240 --> 00:18:41,970
it's going to be stored in the variable username.

471
00:18:41,970 --> 00:18:43,950
If I want to display that back to the screen,

472
00:18:43,950 --> 00:18:48,270
I would then type echo quote hello dollar sign username

473
00:18:48,270 --> 00:18:50,460
exclamation point end quote.

474
00:18:50,460 --> 00:18:53,430
And so what this would look like is please enter your name.

475
00:18:53,430 --> 00:18:54,720
I would type in Jason,

476
00:18:54,720 --> 00:18:55,620
hit enter,

477
00:18:55,620 --> 00:18:57,707
and then you would see hello Jason.

478
00:18:57,707 --> 00:19:01,230
That's the idea of input and output to a screen.

479
00:19:01,230 --> 00:19:02,567
Now in addition to inputting and outputting

480
00:19:02,567 --> 00:19:03,960
things to the screen,

481
00:19:03,960 --> 00:19:07,410
you can also read or write data into files.

482
00:19:07,410 --> 00:19:08,820
If you want to do this in Bash,

483
00:19:08,820 --> 00:19:10,110
it's quite simple.

484
00:19:10,110 --> 00:19:11,700
You're going to create a variable name

485
00:19:11,700 --> 00:19:13,320
that's going to act as that file.

486
00:19:13,320 --> 00:19:14,153
For instance,

487
00:19:14,153 --> 00:19:15,120
temp file.

488
00:19:15,120 --> 00:19:18,240
You're going to set that equal to dollar sign parenthesis

489
00:19:18,240 --> 00:19:21,480
less than the file name end parenthesis.

490
00:19:21,480 --> 00:19:23,910
So I might use something like temp file

491
00:19:23,910 --> 00:19:27,330
equals dollar sign parenthesis less than test

492
00:19:27,330 --> 00:19:29,670
dot txt end parenthesis.

493
00:19:29,670 --> 00:19:32,370
By doing this I have just set all the contents

494
00:19:32,370 --> 00:19:36,060
of test dot txt into the temporary file.

495
00:19:36,060 --> 00:19:38,190
Now if I want to show the contents of that file,

496
00:19:38,190 --> 00:19:41,190
I'll simply use echo dollar sign temp file,

497
00:19:41,190 --> 00:19:43,290
and that'll display the contents of that file

498
00:19:43,290 --> 00:19:46,080
that I just put in that variable to my screen.

499
00:19:46,080 --> 00:19:46,950
Now on the other hand,

500
00:19:46,950 --> 00:19:49,020
if I want to send data to a file,

501
00:19:49,020 --> 00:19:50,820
I can use the greater than symbol

502
00:19:50,820 --> 00:19:52,620
instead of the less than symbol.

503
00:19:52,620 --> 00:19:54,510
Less than means input.

504
00:19:54,510 --> 00:19:56,103
Greater than means output.

505
00:19:56,103 --> 00:19:58,650
Now there's two ways to write to a file.

506
00:19:58,650 --> 00:20:01,740
One is to use the single greater than sign.

507
00:20:01,740 --> 00:20:02,573
When you do this,

508
00:20:02,573 --> 00:20:06,030
any input you give is going to go into that file.

509
00:20:06,030 --> 00:20:08,130
If that file already exists,

510
00:20:08,130 --> 00:20:11,130
it's actually going to be overwritten with what you put there.

511
00:20:11,130 --> 00:20:13,530
Now if you want to append things to that file,

512
00:20:13,530 --> 00:20:15,960
you're going to use a double greater than sign.

513
00:20:15,960 --> 00:20:16,950
So for example,

514
00:20:16,950 --> 00:20:18,840
if I said echo quote

515
00:20:18,840 --> 00:20:21,120
this is now going to be added to the end of the file

516
00:20:21,120 --> 00:20:23,087
as of the next line end quote

517
00:20:23,087 --> 00:20:26,700
greater than greater than test dot txt,

518
00:20:26,700 --> 00:20:28,440
that's exactly what's going to happen.

519
00:20:28,440 --> 00:20:30,810
That string I just typed is going to be echoed

520
00:20:30,810 --> 00:20:32,250
instead of going to the screen,

521
00:20:32,250 --> 00:20:34,980
it's going to go into the file at the end of the file

522
00:20:34,980 --> 00:20:37,560
without overriding the current contents.

523
00:20:37,560 --> 00:20:40,080
All right let's go ahead and take a look at a short script

524
00:20:40,080 --> 00:20:42,990
written in Bash and try to understand what it's doing.

525
00:20:42,990 --> 00:20:46,507
Well the first command we have is if dollar sign one

526
00:20:46,507 --> 00:20:49,080
does not equal empty.

527
00:20:49,080 --> 00:20:50,340
What is that telling us?

528
00:20:50,340 --> 00:20:53,130
It's saying that if there is nothing there,

529
00:20:53,130 --> 00:20:54,480
then don't do anything.

530
00:20:54,480 --> 00:20:56,760
But if it's not empty,

531
00:20:56,760 --> 00:21:00,450
then our target file is going to equal dollar sign one,

532
00:21:00,450 --> 00:21:01,800
that variable.

533
00:21:01,800 --> 00:21:03,780
We're going to set our report directory

534
00:21:03,780 --> 00:21:06,390
to var slash log slash nmap.

535
00:21:06,390 --> 00:21:08,190
So we're probably going to be doing something with nmap

536
00:21:08,190 --> 00:21:10,500
if we're setting it to the nmap directory.

537
00:21:10,500 --> 00:21:14,760
Next for target in dollar sign cat target file.

538
00:21:14,760 --> 00:21:17,511
Now there we can see that for the variable target,

539
00:21:17,511 --> 00:21:20,767
we are going to assign each line inside that target file

540
00:21:20,767 --> 00:21:22,680
to the value of target,

541
00:21:22,680 --> 00:21:24,360
and then run through that loop.

542
00:21:24,360 --> 00:21:25,830
Once we run out of lines,

543
00:21:25,830 --> 00:21:27,870
that would be the end of that for loop,

544
00:21:27,870 --> 00:21:30,150
and we will be finished with doing these commands.

545
00:21:30,150 --> 00:21:32,730
Next we're going to echo scanning target,

546
00:21:32,730 --> 00:21:34,710
whatever that target is that we just pulled in

547
00:21:34,710 --> 00:21:37,860
from that target file. So what do we have on the next line?

548
00:21:37,860 --> 00:21:42,180
Well we have slash user slash bin slash nmap dash ON

549
00:21:42,180 --> 00:21:43,290
and then a lot of stuff,

550
00:21:43,290 --> 00:21:44,123
as you can see,

551
00:21:44,123 --> 00:21:45,477
it takes up over two lines.

552
00:21:45,477 --> 00:21:47,550
Now what is this telling us to do?

553
00:21:47,550 --> 00:21:51,240
Well this is saying we're going to run the nmap command

554
00:21:51,240 --> 00:21:53,220
and we're going to use it with these different parameters.

555
00:21:53,220 --> 00:21:54,677
And then we have the done.

556
00:21:54,677 --> 00:21:58,290
Otherwise we're going to echo you did not provide any command

557
00:21:58,290 --> 00:22:03,290
line options usage program parenthesis file echo echo

558
00:22:03,480 --> 00:22:06,390
and then fi to end the if loop.

559
00:22:06,390 --> 00:22:09,300
So what is this short Bash script really doing for us?

560
00:22:09,300 --> 00:22:11,100
Have you figured it out yet?

561
00:22:11,100 --> 00:22:12,411
Well if not pause the video,

562
00:22:12,411 --> 00:22:13,680
look through it,

563
00:22:13,680 --> 00:22:15,510
and then restart it so you can see

564
00:22:15,510 --> 00:22:17,610
if you got the right answer.

565
00:22:17,610 --> 00:22:18,570
All right you're back?

566
00:22:18,570 --> 00:22:19,403
Great.

567
00:22:19,403 --> 00:22:20,670
So what is this script doing?

568
00:22:20,670 --> 00:22:22,920
Well it's going to take in from the command line

569
00:22:22,920 --> 00:22:25,170
we're going to run it by writing the program name,

570
00:22:25,170 --> 00:22:26,010
the script,

571
00:22:26,010 --> 00:22:28,170
and then giving it a file.

572
00:22:28,170 --> 00:22:30,480
Every time there is something in that file,

573
00:22:30,480 --> 00:22:32,940
like an IP address or a domain name,

574
00:22:32,940 --> 00:22:35,460
it's going to run an nmap scan against it.

575
00:22:35,460 --> 00:22:37,650
So all this command is doing is allowing me

576
00:22:37,650 --> 00:22:40,830
to take whatever inputs from a file,

577
00:22:40,830 --> 00:22:43,200
one per line for IP addresses

578
00:22:43,200 --> 00:22:45,960
and run a different scan on them each time.

579
00:22:45,960 --> 00:22:46,950
So in this case,

580
00:22:46,950 --> 00:22:48,480
I'm going to pull the file in,

581
00:22:48,480 --> 00:22:50,610
I'm going to read one at a time from there,

582
00:22:50,610 --> 00:22:52,110
and every time there's something on the line

583
00:22:52,110 --> 00:22:53,100
and it's not empty,

584
00:22:53,100 --> 00:22:55,020
I'm going to run an nmap scan against it.

585
00:22:55,020 --> 00:22:56,699
Now what is this nmap scan doing?

586
00:22:56,699 --> 00:22:59,580
Well this is a slow comprehensive scan.

587
00:22:59,580 --> 00:23:00,810
We're using T4,

588
00:23:00,810 --> 00:23:02,400
which is not too aggressive.

589
00:23:02,400 --> 00:23:03,480
We're using dash a,

590
00:23:03,480 --> 00:23:04,740
which searches for everything

591
00:23:04,740 --> 00:23:06,960
including OS detection and versioning.

592
00:23:06,960 --> 00:23:09,120
We're doing SS for a sin scan.

593
00:23:09,120 --> 00:23:13,680
We're using a dash ON for output files in nmap format,

594
00:23:13,680 --> 00:23:16,320
and each one is going to be saved to its own file

595
00:23:16,320 --> 00:23:18,240
named target dot nmap.

596
00:23:18,240 --> 00:23:20,580
So if I had three IP addresses,

597
00:23:20,580 --> 00:23:23,190
say I had scanme.nmap.org,

598
00:23:23,190 --> 00:23:27,150
Jason ion.com and Diontraining.com,

599
00:23:27,150 --> 00:23:28,620
it's going to pull each of those.

600
00:23:28,620 --> 00:23:31,950
It's going to do a full nmap scan and save a file,

601
00:23:31,950 --> 00:23:33,891
Jasondion.com dot nmap,

602
00:23:33,891 --> 00:23:36,360
Diontraining.com dot nmap,

603
00:23:36,360 --> 00:23:38,790
right? And I can go back and look at those results later.

604
00:23:38,790 --> 00:23:39,990
So I can run this script,

605
00:23:39,990 --> 00:23:40,823
go home,

606
00:23:40,823 --> 00:23:43,470
come back the next day and have all my scans completed,

607
00:23:43,470 --> 00:23:44,700
it's really great.

608
00:23:44,700 --> 00:23:46,170
And so instead of me having to run the scan

609
00:23:46,170 --> 00:23:48,240
three different times on three different IPS,

610
00:23:48,240 --> 00:23:49,800
I can just give it a file

611
00:23:49,800 --> 00:23:51,600
and the script will pull the information out

612
00:23:51,600 --> 00:23:53,220
and run those scans for me.

613
00:23:53,220 --> 00:23:56,700
So what might a question like this look like on the exam?

614
00:23:56,700 --> 00:23:59,250
Well they might give you something like this and then say,

615
00:23:59,250 --> 00:24:00,690
what's the function of it?

616
00:24:00,690 --> 00:24:02,871
And the correct answer would be that this is performing

617
00:24:02,871 --> 00:24:06,600
an nmap scan against targets provided from an input file,

618
00:24:06,600 --> 00:24:08,040
something like that right?

619
00:24:08,040 --> 00:24:09,030
That's the idea here.

620
00:24:09,030 --> 00:24:11,520
And so you don't need to understand every single nuance

621
00:24:11,520 --> 00:24:12,450
of this script,

622
00:24:12,450 --> 00:24:14,691
but you should be able to identify that it's a Bash script

623
00:24:14,691 --> 00:24:17,370
and what the basic function is.

624
00:24:17,370 --> 00:24:18,300
In this case,

625
00:24:18,300 --> 00:24:20,040
it's going to go through a file,

626
00:24:20,040 --> 00:24:22,170
read each time what's in that file,

627
00:24:22,170 --> 00:24:23,913
and run an nmap scan against them.

