WEBVTT

1
00:00:00.040 --> 00:00:02.399
<v Speaker 1>All right, get ready to dive into the world to

2
00:00:02.480 --> 00:00:05.200
<v Speaker 1>the Linux command line. Yeah, we're going to turn you

3
00:00:05.240 --> 00:00:09.480
<v Speaker 1>into a command line ninja with this twenty twenty one

4
00:00:09.800 --> 00:00:13.839
<v Speaker 1>edition of the Linux command Line and Shell Scripting Bible.

5
00:00:14.480 --> 00:00:16.480
<v Speaker 2>This book, oh wow, the Bible.

6
00:00:16.559 --> 00:00:17.559
<v Speaker 1>Huh, it's a big one.

7
00:00:17.679 --> 00:00:18.000
<v Speaker 2>Yeah.

8
00:00:18.039 --> 00:00:21.399
<v Speaker 1>We've got basic commands, advanced commands. Yeah, we're going to

9
00:00:21.399 --> 00:00:25.480
<v Speaker 1>get into managing files and directories, understanding how the shell

10
00:00:25.559 --> 00:00:29.359
<v Speaker 1>actually works, working with data, and then even getting into

11
00:00:29.399 --> 00:00:30.600
<v Speaker 1>the scripting side of things.

12
00:00:30.800 --> 00:00:31.960
<v Speaker 2>Yeah, this is going to be fun.

13
00:00:32.079 --> 00:00:34.920
<v Speaker 1>So you navigate the file system like a pro, write

14
00:00:35.000 --> 00:00:36.119
<v Speaker 1>some really cool scripts.

15
00:00:37.479 --> 00:00:39.840
<v Speaker 2>I think a good place to start would be just

16
00:00:39.880 --> 00:00:42.159
<v Speaker 2>talking about the different ways that you can even access

17
00:00:42.240 --> 00:00:43.119
<v Speaker 2>the command line.

18
00:00:43.240 --> 00:00:46.000
<v Speaker 1>Okay, yeah, that's a good point. So you've got like

19
00:00:46.320 --> 00:00:51.159
<v Speaker 1>virtual consoles, graphical terminal emulators. That's just like a fancy

20
00:00:51.200 --> 00:00:52.359
<v Speaker 1>way of saying the same thing.

21
00:00:52.560 --> 00:00:55.399
<v Speaker 2>Well, I would say it's important to know the difference

22
00:00:55.759 --> 00:00:58.560
<v Speaker 2>because it affects how you interact with the system. So

23
00:00:58.679 --> 00:01:01.520
<v Speaker 2>when you think about virtual consoles, you want to think

24
00:01:01.560 --> 00:01:05.000
<v Speaker 2>about it's like a direct connection to your system's heart.

25
00:01:05.439 --> 00:01:08.439
<v Speaker 2>It runs right on the system memory. Oh, so it

26
00:01:08.439 --> 00:01:12.760
<v Speaker 2>gives you that old school no frills command line experience. Now,

27
00:01:12.879 --> 00:01:16.719
<v Speaker 2>terminal emulators are like command line windows within your graphical

28
00:01:16.760 --> 00:01:20.560
<v Speaker 2>desktop environment. Okay, they're going to give you more flexibility

29
00:01:20.560 --> 00:01:23.319
<v Speaker 2>and features, but they do have a little bit of

30
00:01:23.359 --> 00:01:24.560
<v Speaker 2>a performance trade off.

31
00:01:25.280 --> 00:01:27.799
<v Speaker 1>Yeah, I guess that makes sense. It has to run

32
00:01:27.840 --> 00:01:31.439
<v Speaker 1>inside of the graphical environment. Okay, So choosing between those

33
00:01:31.439 --> 00:01:33.120
<v Speaker 1>two is like choosing if you're going to be a

34
00:01:33.120 --> 00:01:35.879
<v Speaker 1>survivalist or if you want like the modern conveniences of

35
00:01:35.879 --> 00:01:40.200
<v Speaker 1>the graphical environment. But in both cases you're still using

36
00:01:40.200 --> 00:01:42.560
<v Speaker 1>that command line. So now that we're in the command line,

37
00:01:43.239 --> 00:01:45.120
<v Speaker 1>how do you find your way around? It's not like

38
00:01:45.599 --> 00:01:47.920
<v Speaker 1>Windows with folders and icons and all of that.

39
00:01:47.920 --> 00:01:51.359
<v Speaker 2>That's right. So we've got the Linux file structure. It

40
00:01:51.640 --> 00:01:53.840
<v Speaker 2>is quite a bit different from what you might be

41
00:01:54.040 --> 00:01:58.200
<v Speaker 2>used to, but once you grasp it, it's pretty logical

42
00:01:58.319 --> 00:02:01.560
<v Speaker 2>actually and efficient. Fit like a tree with the root

43
00:02:01.599 --> 00:02:04.840
<v Speaker 2>directory as the trunk. Everything kind of branches out from there.

44
00:02:05.000 --> 00:02:05.439
<v Speaker 1>I see.

45
00:02:05.480 --> 00:02:08.759
<v Speaker 2>And then here's where it gets interesting. Mount points Okay,

46
00:02:08.759 --> 00:02:10.560
<v Speaker 2>you know those are those connectors that let you attach

47
00:02:10.599 --> 00:02:14.719
<v Speaker 2>additional storage devices like hard drives USB drives, Yeah, and

48
00:02:14.759 --> 00:02:17.560
<v Speaker 2>make them appear as part of this unified tree structure.

49
00:02:17.680 --> 00:02:20.560
<v Speaker 1>So no matter where I plug a new device in,

50
00:02:20.960 --> 00:02:22.000
<v Speaker 1>it's going to show.

51
00:02:21.879 --> 00:02:23.439
<v Speaker 2>Up in that one seamlessly integrated.

52
00:02:23.479 --> 00:02:27.400
<v Speaker 1>Okay, it's pretty cool. But with all those directories and files,

53
00:02:27.800 --> 00:02:29.560
<v Speaker 1>how do you it can get.

54
00:02:29.439 --> 00:02:32.759
<v Speaker 2>A little bit daunting. Yeah, especially with those really long

55
00:02:32.800 --> 00:02:34.120
<v Speaker 2>file names that Lennox.

56
00:02:33.840 --> 00:02:36.039
<v Speaker 1>Is known for. Right, yeah, yeah, exactly, exactly.

57
00:02:36.159 --> 00:02:40.199
<v Speaker 2>Yeah. So you've got a master tab completion. Okay, that's

58
00:02:40.240 --> 00:02:43.159
<v Speaker 2>your first step towards being a command line ninja. Right,

59
00:02:43.319 --> 00:02:46.199
<v Speaker 2>just start typing a command or file name, hit the

60
00:02:46.240 --> 00:02:49.280
<v Speaker 2>tab key, and then the shell will just magically complete

61
00:02:49.319 --> 00:02:51.199
<v Speaker 2>it for you. It's going to give you suggestions. It

62
00:02:51.240 --> 00:02:52.520
<v Speaker 2>is a real time saver, right.

63
00:02:52.479 --> 00:02:56.199
<v Speaker 1>Find me up for that. So I've got tab completion.

64
00:02:56.439 --> 00:02:57.360
<v Speaker 1>What other tips?

65
00:02:57.759 --> 00:02:59.879
<v Speaker 2>Okay? So another tip is to look out for those

66
00:03:00.039 --> 00:03:00.840
<v Speaker 2>hidden files.

67
00:03:01.000 --> 00:03:01.240
<v Speaker 1>Okay.

68
00:03:01.319 --> 00:03:05.240
<v Speaker 2>They start with a period, and they're normally invisible, right okay,

69
00:03:05.479 --> 00:03:09.000
<v Speaker 2>and they often contain some pretty important configuration settings or

70
00:03:09.080 --> 00:03:12.199
<v Speaker 2>system data. So if you ever need to delve into

71
00:03:12.280 --> 00:03:15.919
<v Speaker 2>that hidden world, the LSA command is your go to.

72
00:03:16.439 --> 00:03:19.080
<v Speaker 2>It's like putting on X ray vision for the file system.

73
00:03:19.159 --> 00:03:21.080
<v Speaker 1>Oh okay, So I need to be careful not to

74
00:03:21.159 --> 00:03:24.879
<v Speaker 1>delete anything that I can't see them. If it's important, you.

75
00:03:24.879 --> 00:03:26.639
<v Speaker 2>Don't want to accidentally delete something important?

76
00:03:26.800 --> 00:03:31.120
<v Speaker 1>Yeah, yeah, okay, Now let's get into actually managing these files, right,

77
00:03:31.240 --> 00:03:33.400
<v Speaker 1>I mean, what good is a command line if you

78
00:03:33.479 --> 00:03:36.479
<v Speaker 1>can't move, copy, delete these files?

79
00:03:36.800 --> 00:03:40.639
<v Speaker 2>Absolutely, So this book it dives into those essential commands

80
00:03:40.919 --> 00:03:44.520
<v Speaker 2>CEE for copying, m V for moving or renaming, and

81
00:03:44.599 --> 00:03:47.960
<v Speaker 2>then of course we've got the infamous RMM for deleting. Yeah,

82
00:03:48.039 --> 00:03:50.919
<v Speaker 2>but before you go on a deleting spree, we've got

83
00:03:51.000 --> 00:03:51.800
<v Speaker 2>to talk about.

84
00:03:51.560 --> 00:03:53.759
<v Speaker 1>In noodes innodess a little technical.

85
00:03:53.879 --> 00:03:56.479
<v Speaker 2>Yeah, they are a little technical, but they're also very cool.

86
00:03:56.800 --> 00:04:00.400
<v Speaker 2>They're like unique fingerprints for each file. So even if

87
00:04:00.439 --> 00:04:03.039
<v Speaker 2>you change a file's name or move it, it's in

88
00:04:03.159 --> 00:04:04.400
<v Speaker 2>a number stays the same.

89
00:04:04.599 --> 00:04:07.000
<v Speaker 1>So it's not just about the name, that's right, it's

90
00:04:07.039 --> 00:04:10.319
<v Speaker 1>an underlying identifier. Okay, So imagine if you need to

91
00:04:10.319 --> 00:04:13.319
<v Speaker 1>find a file that's been moved or renamed. In odes

92
00:04:13.360 --> 00:04:15.759
<v Speaker 1>are your secret weapon. I see, Yeah, you can find

93
00:04:15.759 --> 00:04:17.399
<v Speaker 1>that file no matter where it is. Wow.

94
00:04:17.560 --> 00:04:21.399
<v Speaker 2>Okay, yeah, Now what about dealing with the output of commands?

95
00:04:22.079 --> 00:04:24.439
<v Speaker 2>Sometimes you get this massive wall.

96
00:04:24.240 --> 00:04:26.199
<v Speaker 1>Of text that's right scrolling by.

97
00:04:26.480 --> 00:04:28.560
<v Speaker 2>Is there a way to kind of capture that information?

98
00:04:28.800 --> 00:04:32.040
<v Speaker 1>Yes, So that's where we've got output redirection. Okay, this

99
00:04:32.120 --> 00:04:34.480
<v Speaker 1>is one of those aha moments. Once you learn how

100
00:04:34.480 --> 00:04:37.759
<v Speaker 1>to use it. The symbol is your friend here. Okay,

101
00:04:38.199 --> 00:04:41.639
<v Speaker 1>you can readirect the output of a command to a file,

102
00:04:41.759 --> 00:04:44.279
<v Speaker 1>so instead of seeing it on the screen, you can

103
00:04:44.480 --> 00:04:47.160
<v Speaker 1>capture it, put it in a file, and use it

104
00:04:47.279 --> 00:04:51.399
<v Speaker 1>later for analysis or reference. Oh that's so useful. Yeah,

105
00:04:51.519 --> 00:04:53.160
<v Speaker 1>instead of it just flying by on the screen.

106
00:04:53.240 --> 00:04:54.360
<v Speaker 2>Yeah, just capture it.

107
00:04:54.279 --> 00:04:55.680
<v Speaker 1>You can actually. Yeah, okay, brilliant.

108
00:04:55.759 --> 00:04:56.720
<v Speaker 2>Yeah, it's a good one.

109
00:04:56.839 --> 00:05:00.639
<v Speaker 1>Now we keep hearing the word shell. Exactly is a shell?

110
00:05:00.879 --> 00:05:02.160
<v Speaker 2>Ah? Yes, the shell?

111
00:05:02.240 --> 00:05:03.399
<v Speaker 1>And why should I care about it?

112
00:05:03.399 --> 00:05:05.879
<v Speaker 2>The shell? So think about this. This is your command

113
00:05:05.879 --> 00:05:09.480
<v Speaker 2>line interpreter, the bridge between you and the Linux kernel,

114
00:05:10.000 --> 00:05:12.759
<v Speaker 2>which is the heart of the operating system. Right, So

115
00:05:12.839 --> 00:05:15.600
<v Speaker 2>it's taking your commands, figuring out what you mean, and

116
00:05:15.680 --> 00:05:18.240
<v Speaker 2>then it instructs the kernel to make it happen.

117
00:05:18.439 --> 00:05:18.759
<v Speaker 1>Gotcha.

118
00:05:18.879 --> 00:05:21.199
<v Speaker 2>And there's not just one shell. There's several.

119
00:05:21.360 --> 00:05:23.839
<v Speaker 1>Oh interesting, So I don't have to just use one shell.

120
00:05:24.000 --> 00:05:27.639
<v Speaker 2>No, And this book delves into the different types of shells,

121
00:05:27.720 --> 00:05:30.800
<v Speaker 2>like the very popular beast shell off in the default,

122
00:05:31.399 --> 00:05:35.040
<v Speaker 2>and then you have alternatives like TS and DASH.

123
00:05:35.079 --> 00:05:38.079
<v Speaker 1>Wow. Okay, so there's each one has its choices.

124
00:05:38.199 --> 00:05:42.000
<v Speaker 2>Yeah, they each have their own personality, their own quirks strengths.

125
00:05:42.079 --> 00:05:44.279
<v Speaker 1>So it's like choosing your weapon, choosing your.

126
00:05:44.519 --> 00:05:47.519
<v Speaker 2>Exactly which one fits your style and needs.

127
00:05:47.800 --> 00:05:51.560
<v Speaker 1>Now, every time I hit enter, it creates a child process.

128
00:05:51.839 --> 00:05:54.639
<v Speaker 2>That's right, a child process to handle that command.

129
00:05:54.759 --> 00:05:56.839
<v Speaker 1>So there's a whole family going on every time I

130
00:05:56.920 --> 00:05:57.360
<v Speaker 1>hit a key.

131
00:05:57.720 --> 00:06:00.360
<v Speaker 2>It's like a parent shell gives both to it childs

132
00:06:00.360 --> 00:06:02.079
<v Speaker 2>shell to kind of carry out your instructions.

133
00:06:02.319 --> 00:06:05.480
<v Speaker 1>I see. Okay. And then they also mentioned subshells are

134
00:06:05.519 --> 00:06:08.399
<v Speaker 1>subshells like the rebellious teenager of the shell world.

135
00:06:08.680 --> 00:06:09.079
<v Speaker 2>Huh.

136
00:06:09.120 --> 00:06:09.560
<v Speaker 1>I like that.

137
00:06:10.399 --> 00:06:15.120
<v Speaker 2>Yeah, kind of subshells are temporary shells created within your

138
00:06:15.160 --> 00:06:18.720
<v Speaker 2>main shell. Okay, So think of it as a sandbox

139
00:06:19.160 --> 00:06:22.759
<v Speaker 2>where you can play around commands and environment variables without

140
00:06:22.759 --> 00:06:24.399
<v Speaker 2>really affecting your main shell.

141
00:06:24.560 --> 00:06:26.519
<v Speaker 1>So if I mess up in the subshell, it doesn't

142
00:06:26.519 --> 00:06:28.160
<v Speaker 1>blow up my main shell exactly.

143
00:06:28.240 --> 00:06:30.160
<v Speaker 2>That's the beauty of it. What happens in the subshell

144
00:06:30.240 --> 00:06:31.279
<v Speaker 2>stays in the subshell.

145
00:06:31.439 --> 00:06:33.360
<v Speaker 1>Okay, I like that. Yeah, all right, now let's talk

146
00:06:33.360 --> 00:06:34.639
<v Speaker 1>about environment variables.

147
00:06:34.879 --> 00:06:35.199
<v Speaker 2>Hmmm.

148
00:06:36.480 --> 00:06:37.959
<v Speaker 1>That sounds a little bit intimidating.

149
00:06:38.079 --> 00:06:40.279
<v Speaker 2>I know, I know they can be. Yeah, but think

150
00:06:40.279 --> 00:06:45.079
<v Speaker 2>about like this. They're the settings that control how your

151
00:06:45.279 --> 00:06:48.759
<v Speaker 2>shell and other programs behave. So it's like a behind

152
00:06:48.800 --> 00:06:50.720
<v Speaker 2>the scenes control panel for your system.

153
00:06:50.920 --> 00:06:51.399
<v Speaker 1>I see.

154
00:06:51.519 --> 00:06:56.319
<v Speaker 2>Now you have global environment variables those apply system wide, okay,

155
00:06:56.399 --> 00:06:59.240
<v Speaker 2>and then you have local ones, which are specific to

156
00:06:59.399 --> 00:07:00.920
<v Speaker 2>your current shell session.

157
00:07:01.120 --> 00:07:04.000
<v Speaker 1>So global or like the laws of the Lenox universe,

158
00:07:04.480 --> 00:07:06.600
<v Speaker 1>and local are like my own personal preference.

159
00:07:06.720 --> 00:07:08.839
<v Speaker 2>There you go. Okay, that's a great way to put it.

160
00:07:08.920 --> 00:07:17.439
<v Speaker 1>Now. The book mentions these VIP environment variables. Yes, like path, home, shell, term.

161
00:07:18.120 --> 00:07:18.720
<v Speaker 2>It's a path.

162
00:07:18.839 --> 00:07:19.600
<v Speaker 1>Yeah, where are those?

163
00:07:19.680 --> 00:07:22.639
<v Speaker 2>So? Path that tells the shell where to look for

164
00:07:22.759 --> 00:07:26.360
<v Speaker 2>executable commands. Okay, so it's like a roadmap guiding the

165
00:07:26.360 --> 00:07:27.800
<v Speaker 2>shell to find those tools.

166
00:07:27.920 --> 00:07:28.240
<v Speaker 1>Gotcha.

167
00:07:28.360 --> 00:07:32.560
<v Speaker 2>And then home that points to your home directory, your

168
00:07:32.600 --> 00:07:37.519
<v Speaker 2>personal space within that file system. Shell specifies which shell

169
00:07:37.639 --> 00:07:41.279
<v Speaker 2>you're using, and then term defines your terminal type okay,

170
00:07:41.319 --> 00:07:44.680
<v Speaker 2>so that programs understand how to display information properly.

171
00:07:44.800 --> 00:07:46.920
<v Speaker 1>So these variables are kind of like setting the stage

172
00:07:46.920 --> 00:07:47.920
<v Speaker 1>for how everything's going to do.

173
00:07:48.040 --> 00:07:50.120
<v Speaker 2>That's right, how everything is going to run okay. Yeah,

174
00:07:50.279 --> 00:07:55.000
<v Speaker 2>and then you've got commands like set envy and print him.

175
00:07:55.040 --> 00:07:57.000
<v Speaker 2>Those are going to be your tools for viewing and

176
00:07:57.120 --> 00:08:00.079
<v Speaker 2>manipulating these environment variables.

177
00:08:00.120 --> 00:08:04.319
<v Speaker 1>So we can actually modify these settings totally customize our environments. Yep.

178
00:08:04.680 --> 00:08:06.480
<v Speaker 1>All right, Now we need to talk about these shell

179
00:08:06.560 --> 00:08:09.319
<v Speaker 1>startup files okay, before we get too far into the

180
00:08:09.800 --> 00:08:10.600
<v Speaker 1>scripting side.

181
00:08:10.720 --> 00:08:13.720
<v Speaker 2>Right, So these are those secret ingredients that make your

182
00:08:13.800 --> 00:08:19.519
<v Speaker 2>shell experience really personalized. Okay, So shell startup files like

183
00:08:19.639 --> 00:08:24.160
<v Speaker 2>et cetera profile, dot bash profile, dot bash rc. There're

184
00:08:24.240 --> 00:08:26.600
<v Speaker 2>scripts that run every time you log in or start

185
00:08:26.639 --> 00:08:27.560
<v Speaker 2>a new shell session.

186
00:08:27.639 --> 00:08:29.199
<v Speaker 1>So it's like a set of instructions for how the

187
00:08:29.199 --> 00:08:29.759
<v Speaker 1>shell's going.

188
00:08:29.680 --> 00:08:31.480
<v Speaker 2>To exactly how it's going to set up. Okay, you

189
00:08:31.480 --> 00:08:35.320
<v Speaker 2>know you can customize your command prompt, set environment variables,

190
00:08:35.320 --> 00:08:38.360
<v Speaker 2>define aliases for those frequently used commands. Wow.

191
00:08:38.399 --> 00:08:40.720
<v Speaker 1>So it's like my own little personal exactly. It's like

192
00:08:40.759 --> 00:08:41.559
<v Speaker 1>your assistant.

193
00:08:41.600 --> 00:08:43.840
<v Speaker 2>It's like having a personal assistant just for your shell,

194
00:08:44.080 --> 00:08:46.000
<v Speaker 2>taking care of all the yeah, taking care of all

195
00:08:46.000 --> 00:08:48.440
<v Speaker 2>the tedious stuff so you can focus on the fun stuff.

196
00:08:48.639 --> 00:08:51.159
<v Speaker 1>Okay, So now we've got our environments set up, it's

197
00:08:51.200 --> 00:08:52.720
<v Speaker 1>time to write a shell script.

198
00:08:52.799 --> 00:08:53.799
<v Speaker 2>All right? Are you ready?

199
00:08:53.879 --> 00:08:57.360
<v Speaker 1>Yeah? How do we bring these shell scripts to life?

200
00:08:57.399 --> 00:08:59.960
<v Speaker 2>All right? So first thing you want to do is

201
00:09:00.120 --> 00:09:03.080
<v Speaker 2>you want to create a simple text file. Okay, you're

202
00:09:03.080 --> 00:09:06.639
<v Speaker 2>going to write your commands in plain text, just like

203
00:09:06.679 --> 00:09:08.879
<v Speaker 2>you would type them at the command line, right, and

204
00:09:08.919 --> 00:09:11.799
<v Speaker 2>then you need to make that script executable using the

205
00:09:11.879 --> 00:09:12.639
<v Speaker 2>chron command.

206
00:09:13.080 --> 00:09:15.159
<v Speaker 1>So we're giving it permission to do its things.

207
00:09:15.200 --> 00:09:18.039
<v Speaker 2>Exactly, you're giving it permission to do its thing. You're

208
00:09:18.120 --> 00:09:20.840
<v Speaker 2>changing the file permissions and telling the system, hey, this

209
00:09:20.879 --> 00:09:23.320
<v Speaker 2>is a program. This can be executed.

210
00:09:23.519 --> 00:09:26.759
<v Speaker 1>Gotcha. So what kind of commands can we put inside

211
00:09:26.799 --> 00:09:27.559
<v Speaker 1>of these scripts?

212
00:09:27.679 --> 00:09:31.159
<v Speaker 2>So you've got the Echo command. That's your basic communication tool.

213
00:09:31.399 --> 00:09:31.799
<v Speaker 1>Okay.

214
00:09:31.919 --> 00:09:34.639
<v Speaker 2>You can display messages on the screen, so it's good

215
00:09:34.639 --> 00:09:38.159
<v Speaker 2>for providing feedback or debugging your script.

216
00:09:38.480 --> 00:09:41.960
<v Speaker 1>So if I wanted to say Hello World, I could

217
00:09:41.960 --> 00:09:42.759
<v Speaker 1>do that with Echo.

218
00:09:42.960 --> 00:09:44.399
<v Speaker 2>You got it. Echo is your friend?

219
00:09:44.679 --> 00:09:47.799
<v Speaker 1>All right? What about making these scripts a little more dynamic,

220
00:09:48.120 --> 00:09:49.679
<v Speaker 1>like working with data?

221
00:09:49.720 --> 00:09:51.840
<v Speaker 2>Ah? Okay, so we're going to bring in variables.

222
00:09:51.919 --> 00:09:52.159
<v Speaker 1>Okay.

223
00:09:52.279 --> 00:09:56.639
<v Speaker 2>Variables are like containers that hold data within your script.

224
00:09:56.840 --> 00:10:00.919
<v Speaker 2>So think of them as like labeled boxes store information

225
00:10:01.679 --> 00:10:05.480
<v Speaker 2>and then refer to that information by that label or

226
00:10:05.679 --> 00:10:06.559
<v Speaker 2>variable name.

227
00:10:06.720 --> 00:10:08.039
<v Speaker 1>So it's like giving the script a memory.

228
00:10:08.080 --> 00:10:10.480
<v Speaker 2>Then you got it. You're giving it a memory. And

229
00:10:10.840 --> 00:10:15.919
<v Speaker 2>this book shows you how to assign values to those variables,

230
00:10:16.440 --> 00:10:19.799
<v Speaker 2>and then use those values within your script. It even

231
00:10:19.840 --> 00:10:22.240
<v Speaker 2>shows you how to capture the output of a command

232
00:10:22.799 --> 00:10:24.200
<v Speaker 2>and store that in a variable.

233
00:10:24.320 --> 00:10:27.039
<v Speaker 1>Really yeah, so I could run a command and then

234
00:10:27.240 --> 00:10:29.679
<v Speaker 1>take that output and use it somewhere else.

235
00:10:29.519 --> 00:10:31.240
<v Speaker 2>And feed it into your script. Yeah.

236
00:10:31.279 --> 00:10:31.960
<v Speaker 1>That's awesome.

237
00:10:32.159 --> 00:10:33.039
<v Speaker 2>Yeah, that's a good one.

238
00:10:33.080 --> 00:10:33.919
<v Speaker 1>So how do you do that?

239
00:10:34.519 --> 00:10:36.679
<v Speaker 2>So there's a couple of ways to do it. One

240
00:10:36.720 --> 00:10:39.519
<v Speaker 2>is using backticks. That's the older syntax okay, and then

241
00:10:39.519 --> 00:10:42.000
<v Speaker 2>you've got the newer syntax for command substitution.

242
00:10:42.159 --> 00:10:42.480
<v Speaker 1>Okay.

243
00:10:42.639 --> 00:10:46.080
<v Speaker 2>Both achieve the same goal. They're capturing the output of

244
00:10:46.080 --> 00:10:49.320
<v Speaker 2>that command to data stream and then you can feed

245
00:10:49.360 --> 00:10:50.919
<v Speaker 2>that into your script, so I.

246
00:10:50.919 --> 00:10:54.360
<v Speaker 1>Can build mini pipelines right inside my script. That's right. Wow, yeah,

247
00:10:54.360 --> 00:10:56.159
<v Speaker 1>pretty cool? Right, this is really cool. Yeah.

248
00:10:56.200 --> 00:10:59.159
<v Speaker 2>So we've covered the foundations of shell scripting here, but

249
00:10:59.240 --> 00:11:00.960
<v Speaker 2>there's so much more to explore.

250
00:11:01.240 --> 00:11:02.919
<v Speaker 1>I'm ready. What's coming up next?

251
00:11:03.000 --> 00:11:05.679
<v Speaker 2>Okay? Well, next we're going to dive into more advanced

252
00:11:05.720 --> 00:11:09.799
<v Speaker 2>scripting techniques like conditional statements and loops. Those allow your

253
00:11:09.840 --> 00:11:12.279
<v Speaker 2>scripts to make decisions and repeat actions.

254
00:11:12.440 --> 00:11:14.639
<v Speaker 1>Okay, cool, let's get into it all right, So.

255
00:11:14.679 --> 00:11:17.399
<v Speaker 2>Are you ready to go beyond those scripting basics and

256
00:11:17.440 --> 00:11:19.039
<v Speaker 2>give those scripts some intelligence.

257
00:11:19.120 --> 00:11:19.559
<v Speaker 1>I'm ready.

258
00:11:19.559 --> 00:11:22.360
<v Speaker 2>How do we do that with conditional statements and loops?

259
00:11:22.720 --> 00:11:24.399
<v Speaker 1>Ooh that sounds interesting.

260
00:11:24.559 --> 00:11:27.120
<v Speaker 2>Yeah, they're really cool. It's like adding a brain to

261
00:11:27.200 --> 00:11:30.159
<v Speaker 2>your script so they can adapt to different situations and

262
00:11:30.279 --> 00:11:33.360
<v Speaker 2>automate those tedious, repetitive tasks. Right.

263
00:11:33.399 --> 00:11:36.000
<v Speaker 1>Oh yeah, yeah, okay, so let's start with conditional statements.

264
00:11:36.320 --> 00:11:38.399
<v Speaker 1>How do those work? It kind of sounds like teaching

265
00:11:38.399 --> 00:11:39.240
<v Speaker 1>the script to think.

266
00:11:39.399 --> 00:11:42.320
<v Speaker 2>Yeah, it's kind of like that the if then statement. Okay,

267
00:11:42.360 --> 00:11:45.440
<v Speaker 2>it's your building block for decision making. You know. Think

268
00:11:45.480 --> 00:11:49.480
<v Speaker 2>of it like a gatekeeper evaluating a condition and only

269
00:11:49.559 --> 00:11:52.159
<v Speaker 2>letting those commands through if the condition is true.

270
00:11:52.480 --> 00:11:55.440
<v Speaker 1>So it's like saying, hey, script, if this is true,

271
00:11:55.480 --> 00:11:58.639
<v Speaker 1>then do that. If not, skip it, that's right. Okay,

272
00:11:59.120 --> 00:12:01.159
<v Speaker 1>what kind of condition can we actually put in there?

273
00:12:01.200 --> 00:12:04.480
<v Speaker 2>Well? Remember those exit status codes. You know, the command

274
00:12:04.679 --> 00:12:07.399
<v Speaker 2>typically exists with the status of zero if it's successful,

275
00:12:07.879 --> 00:12:11.159
<v Speaker 2>or a non zero status if there's an error. Right, right, Well,

276
00:12:11.159 --> 00:12:13.840
<v Speaker 2>conditional statements use those statuses to make decisions.

277
00:12:13.960 --> 00:12:16.759
<v Speaker 1>Oh okay, so the command is actually reporting back to

278
00:12:16.759 --> 00:12:19.159
<v Speaker 1>the script saying hey I did it, or hey I

279
00:12:19.200 --> 00:12:21.600
<v Speaker 1>had a problem that's right. You decide what to do

280
00:12:21.679 --> 00:12:22.639
<v Speaker 1>next exactly.

281
00:12:22.679 --> 00:12:26.240
<v Speaker 2>So in an if then statement, if that preceding command

282
00:12:26.360 --> 00:12:29.639
<v Speaker 2>exits with a zero, the commands in the then block

283
00:12:30.039 --> 00:12:32.440
<v Speaker 2>get executed. Otherwise they get skipped.

284
00:12:32.519 --> 00:12:34.559
<v Speaker 1>Okay, So what if you want to have an alternative

285
00:12:34.679 --> 00:12:37.799
<v Speaker 1>like run these commands if it's true, but if not,

286
00:12:38.039 --> 00:12:38.960
<v Speaker 1>then do something else.

287
00:12:39.159 --> 00:12:40.639
<v Speaker 2>Ah, so you want a backup plan?

288
00:12:40.799 --> 00:12:41.440
<v Speaker 1>Yeah, exactly.

289
00:12:41.440 --> 00:12:44.200
<v Speaker 2>Well that's where if then else comes in. It's giving

290
00:12:44.240 --> 00:12:47.519
<v Speaker 2>your scripts two possible paths. Okay, one for when the

291
00:12:47.519 --> 00:12:49.679
<v Speaker 2>condition is true and one for when it's false.

292
00:12:50.120 --> 00:12:52.639
<v Speaker 1>I like having options. You got it now. I also

293
00:12:52.679 --> 00:12:59.360
<v Speaker 1>see nested if statements. Yes, are those like nsted if statements?

294
00:12:59.440 --> 00:13:03.720
<v Speaker 1>Those rush yes exactly, like those Russian nesting dolls with

295
00:13:03.840 --> 00:13:07.039
<v Speaker 1>one if statement inside of another. Okay, So that allows

296
00:13:07.120 --> 00:13:11.240
<v Speaker 1>you to create more complex decision making logic. You know,

297
00:13:11.320 --> 00:13:13.679
<v Speaker 1>it's like creating a multi level decision tree.

298
00:13:13.759 --> 00:13:16.799
<v Speaker 2>So it's like adding layers of intelligence to that script.

299
00:13:16.960 --> 00:13:17.399
<v Speaker 1>That's right.

300
00:13:17.440 --> 00:13:19.840
<v Speaker 2>It can evaluate more sophisticated scenarios.

301
00:13:19.919 --> 00:13:20.440
<v Speaker 1>Exactly.

302
00:13:20.799 --> 00:13:23.279
<v Speaker 2>Wow. Okay, now we need to talk about loops.

303
00:13:23.759 --> 00:13:27.519
<v Speaker 1>Okay, So loops for those repetitive tasks exactly. Loops are

304
00:13:27.600 --> 00:13:31.039
<v Speaker 1>the workhorses of automation. Okay, the book covers several types

305
00:13:31.080 --> 00:13:32.960
<v Speaker 1>of loops, for loops and wild loops.

306
00:13:33.200 --> 00:13:35.960
<v Speaker 2>You know, imagine if you had to process one hundred files,

307
00:13:36.080 --> 00:13:39.519
<v Speaker 2>or maybe you're waiting for a specific condition to change. Yeah,

308
00:13:40.120 --> 00:13:43.399
<v Speaker 2>you know loops. Let you handle those situations without writing

309
00:13:43.399 --> 00:13:45.159
<v Speaker 2>the same commands over and over again.

310
00:13:45.399 --> 00:13:47.480
<v Speaker 1>Okay, yeah, I can see where that would get really tedious.

311
00:13:47.559 --> 00:13:48.759
<v Speaker 2>Yeah, I would get really tedious.

312
00:13:48.799 --> 00:13:50.159
<v Speaker 1>Okay, let's start with the four loop.

313
00:13:50.440 --> 00:13:51.480
<v Speaker 2>All right. So the four loop.

314
00:13:51.639 --> 00:13:52.440
<v Speaker 1>How does that one work?

315
00:13:52.639 --> 00:13:56.320
<v Speaker 2>It's design to iterate through a list of values, okay,

316
00:13:56.399 --> 00:13:59.320
<v Speaker 2>and execute a set of commands for each value. It's

317
00:13:59.320 --> 00:14:02.480
<v Speaker 2>like a processing You take each item from that list,

318
00:14:02.720 --> 00:14:05.480
<v Speaker 2>you run it through the same set of instructions.

319
00:14:05.759 --> 00:14:07.480
<v Speaker 1>Gotcha. So if I had a list of file names,

320
00:14:07.519 --> 00:14:10.000
<v Speaker 1>I could run the same action on all those files exactly.

321
00:14:10.120 --> 00:14:12.399
<v Speaker 1>That's pretty cool. What about the wile loop?

322
00:14:12.440 --> 00:14:13.559
<v Speaker 2>All right? So the wile loop?

323
00:14:13.559 --> 00:14:14.480
<v Speaker 1>Why would I use that one?

324
00:14:14.559 --> 00:14:18.320
<v Speaker 2>So the wile loop is like this persistent little engine. Okay,

325
00:14:18.399 --> 00:14:23.320
<v Speaker 2>It keeps running as long as a specific condition remains true. Okay,

326
00:14:23.600 --> 00:14:26.399
<v Speaker 2>So it's perfect for situations where you don't know in

327
00:14:26.519 --> 00:14:29.440
<v Speaker 2>advance how many times you need to repeat those commands.

328
00:14:29.879 --> 00:14:33.600
<v Speaker 2>So imagine you're monitoring a system log file okay, and

329
00:14:33.639 --> 00:14:38.000
<v Speaker 2>you're waiting for a specific error message to appear. Yeah,

330
00:14:38.120 --> 00:14:41.600
<v Speaker 2>a while loop can keep checking that file, oh okay

331
00:14:41.720 --> 00:14:43.000
<v Speaker 2>until that message pops out.

332
00:14:43.080 --> 00:14:45.320
<v Speaker 1>Yeah, so it's just constantly checking and checking.

333
00:14:45.120 --> 00:14:47.639
<v Speaker 2>Until exactly continually monitoring.

334
00:14:47.759 --> 00:14:50.399
<v Speaker 1>Okay. What if I need to bail out of a

335
00:14:50.440 --> 00:14:51.120
<v Speaker 1>loop early?

336
00:14:51.720 --> 00:14:55.200
<v Speaker 2>Ah, well, we've got the brake command for that.

337
00:14:55.639 --> 00:14:55.879
<v Speaker 1>Okay.

338
00:14:55.919 --> 00:14:59.120
<v Speaker 2>You know, that's your emergency exit for loops. So if

339
00:14:59.159 --> 00:15:02.759
<v Speaker 2>a certain condition is met within that loop, yeah, break,

340
00:15:03.000 --> 00:15:06.720
<v Speaker 2>we'll stop it right there, preventing any further iteration, like.

341
00:15:06.679 --> 00:15:08.159
<v Speaker 1>The loop stopping Superhero.

342
00:15:08.279 --> 00:15:11.200
<v Speaker 2>That's right, that's right. So what about skipping over certain

343
00:15:11.240 --> 00:15:12.320
<v Speaker 2>iterations of a loop?

344
00:15:12.399 --> 00:15:14.399
<v Speaker 1>Oh? Yeah? What if I want to just process certain

345
00:15:14.440 --> 00:15:17.039
<v Speaker 1>files like that meet certain criteria.

346
00:15:16.639 --> 00:15:19.360
<v Speaker 2>Well, for that, you have the continued command OKA that

347
00:15:19.480 --> 00:15:22.480
<v Speaker 2>lets you jump to the next iteration of the loop

348
00:15:22.799 --> 00:15:24.919
<v Speaker 2>without executing those remaining commands.

349
00:15:25.000 --> 00:15:26.720
<v Speaker 1>It's like, nope, not that one, move on to the

350
00:15:26.759 --> 00:15:30.720
<v Speaker 1>next exactly exactly. Okay. These loop control commands are really cool.

351
00:15:31.080 --> 00:15:34.039
<v Speaker 1>So I've got conditional statements for decision making, we've got

352
00:15:34.080 --> 00:15:37.879
<v Speaker 1>loops for repeating actions. What else can we do to

353
00:15:37.919 --> 00:15:40.480
<v Speaker 1>make our scripts a little more interactive and powerful.

354
00:15:40.639 --> 00:15:43.960
<v Speaker 2>Well, how about giving them the ability to take constructions

355
00:15:44.080 --> 00:15:47.039
<v Speaker 2>directly from the user? Oh okay, you know with command

356
00:15:47.039 --> 00:15:47.759
<v Speaker 2>line parameters.

357
00:15:47.799 --> 00:15:50.399
<v Speaker 1>Okay, so like giving it instructions or settings when I

358
00:15:50.519 --> 00:15:51.080
<v Speaker 1>start the.

359
00:15:51.000 --> 00:15:55.039
<v Speaker 2>Script exactly exactly. You know, you pass information to the

360
00:15:55.080 --> 00:15:58.360
<v Speaker 2>script when you run it, customize its behavior on the fly.

361
00:15:58.720 --> 00:15:59.080
<v Speaker 1>Okay.

362
00:15:59.159 --> 00:16:03.480
<v Speaker 2>Within the script, you access those parameters using special variables

363
00:16:03.519 --> 00:16:06.120
<v Speaker 2>like one dollar, two dollars, and so on. One dollars

364
00:16:06.159 --> 00:16:08.759
<v Speaker 2>is the first parameter, two dollars is the second.

365
00:16:08.879 --> 00:16:11.840
<v Speaker 1>Okay, that's pretty straightforward. What if I've got a script

366
00:16:11.879 --> 00:16:14.399
<v Speaker 1>that takes a bunch of parameters, Well, you know, the.

367
00:16:14.320 --> 00:16:17.559
<v Speaker 2>Book explains special variables like hashtag that gives you the

368
00:16:17.600 --> 00:16:20.480
<v Speaker 2>total number of parameters past ok and then you have

369
00:16:20.799 --> 00:16:22.840
<v Speaker 2>at which lets you access all of them as a

370
00:16:22.840 --> 00:16:23.480
<v Speaker 2>single unit.

371
00:16:23.759 --> 00:16:24.080
<v Speaker 1>Gotcha.

372
00:16:24.200 --> 00:16:27.559
<v Speaker 2>And then there's even a clever trick to access the

373
00:16:27.679 --> 00:16:29.799
<v Speaker 2>very last parameter using ash.

374
00:16:29.960 --> 00:16:30.960
<v Speaker 1>Wow. It's pretty handy.

375
00:16:31.039 --> 00:16:33.720
<v Speaker 2>Yeah, it's pretty handy. So how about those single letter

376
00:16:33.720 --> 00:16:38.080
<v Speaker 2>command line options, right, you know, like L for the long.

377
00:16:37.879 --> 00:16:39.960
<v Speaker 1>Listing with l's Yeah, yeah, exactly.

378
00:16:40.000 --> 00:16:41.360
<v Speaker 2>You can use those in your scripts too.

379
00:16:41.559 --> 00:16:41.879
<v Speaker 1>Really.

380
00:16:42.039 --> 00:16:45.519
<v Speaker 2>Yeah, So the book outlines three ways to handle those options, okay,

381
00:16:45.639 --> 00:16:48.399
<v Speaker 2>so you can process them directly as parameters. You can

382
00:16:48.519 --> 00:16:52.879
<v Speaker 2>use if statements to check for specific options, or the

383
00:16:52.919 --> 00:16:56.200
<v Speaker 2>most elegant approach is to use the get tops command

384
00:16:56.320 --> 00:16:58.720
<v Speaker 2>get tops get tops. You know that's your built in

385
00:16:59.000 --> 00:17:00.279
<v Speaker 2>option parsing wizard.

386
00:17:00.639 --> 00:17:01.120
<v Speaker 1>Oh wow.

387
00:17:01.279 --> 00:17:04.200
<v Speaker 2>It handles both short and long options, whether they have

388
00:17:04.240 --> 00:17:05.519
<v Speaker 2>associated values or not.

389
00:17:05.799 --> 00:17:06.079
<v Speaker 1>Wow.

390
00:17:06.440 --> 00:17:08.880
<v Speaker 2>And you can even specify which options are expected.

391
00:17:09.119 --> 00:17:11.839
<v Speaker 1>So it's kind of streamlining all that option handling exactly.

392
00:17:11.880 --> 00:17:13.759
<v Speaker 2>It streamlines it and makes it more robust.

393
00:17:13.920 --> 00:17:17.880
<v Speaker 1>Okay, very cool. So we've got conditional statements, loops, we've

394
00:17:17.920 --> 00:17:21.359
<v Speaker 1>got these command line parameters and options. Anything else we

395
00:17:21.400 --> 00:17:22.079
<v Speaker 1>can do well.

396
00:17:22.240 --> 00:17:25.440
<v Speaker 2>One of the most powerful techniques is to encapsulate those

397
00:17:25.759 --> 00:17:29.160
<v Speaker 2>reusable code blocks into functions.

398
00:17:29.200 --> 00:17:31.839
<v Speaker 1>Functions okay, yeah, functions in programming.

399
00:17:31.960 --> 00:17:34.000
<v Speaker 2>Yeah, just like in programming. They are like mini scripts

400
00:17:34.000 --> 00:17:37.559
<v Speaker 2>within your main script. They help you avoid repetition and

401
00:17:37.640 --> 00:17:41.079
<v Speaker 2>make it way more readable and maintainable. Okay, it's like

402
00:17:41.119 --> 00:17:43.039
<v Speaker 2>building your own custom command library.

403
00:17:43.200 --> 00:17:46.039
<v Speaker 1>Oh that's cool. So I can create my own commands,

404
00:17:46.440 --> 00:17:46.799
<v Speaker 1>that's right.

405
00:17:46.839 --> 00:17:50.119
<v Speaker 2>And the book walks you through defining those functions, okay,

406
00:17:50.240 --> 00:17:54.440
<v Speaker 2>giving them names, calling them. When you need that specific functionality,

407
00:17:54.839 --> 00:17:57.480
<v Speaker 2>you can even pass arguments to functions, just like you

408
00:17:57.559 --> 00:17:58.839
<v Speaker 2>do with regular commands.

409
00:17:59.119 --> 00:18:01.200
<v Speaker 1>So it's like building as some toolbox of all these

410
00:18:01.200 --> 00:18:05.799
<v Speaker 1>components exactly all right, Now the book mentions this local keyword. Yes,

411
00:18:05.839 --> 00:18:08.119
<v Speaker 1>what is local all about?

412
00:18:08.400 --> 00:18:11.359
<v Speaker 2>So local is your friend when it comes to keeping

413
00:18:11.480 --> 00:18:16.200
<v Speaker 2>variables organized within those functions. It lets you declare variables

414
00:18:16.240 --> 00:18:20.440
<v Speaker 2>that are only visible inside that function. Okay, prevents naming

415
00:18:20.920 --> 00:18:25.160
<v Speaker 2>conflicts with variables in your main scriptstcha, you know, other functions.

416
00:18:25.200 --> 00:18:29.240
<v Speaker 2>It's good practice to use local variables within functions to

417
00:18:29.319 --> 00:18:30.559
<v Speaker 2>keep things nice and tidy.

418
00:18:31.000 --> 00:18:34.119
<v Speaker 1>Okay. So it's like giving each function its own little workspace.

419
00:18:34.200 --> 00:18:36.079
<v Speaker 2>That's right, its own little private.

420
00:18:35.720 --> 00:18:40.079
<v Speaker 1>Workspace prevents them from interfering with each other exactly. Okay. Now,

421
00:18:40.279 --> 00:18:44.319
<v Speaker 1>Linux has a ton of commands and utilities built in.

422
00:18:44.759 --> 00:18:47.680
<v Speaker 1>Are there any external tools? Yes, that can help us

423
00:18:47.720 --> 00:18:48.279
<v Speaker 1>with scripting.

424
00:18:48.839 --> 00:18:51.680
<v Speaker 2>So there is a package called stool Okay, you know,

425
00:18:51.720 --> 00:18:54.200
<v Speaker 2>think of that like your Swiss army knife for scripting.

426
00:18:54.359 --> 00:18:54.559
<v Speaker 1>Right.

427
00:18:54.599 --> 00:18:57.440
<v Speaker 2>It provides a collection of pre built functions for all

428
00:18:57.440 --> 00:19:02.119
<v Speaker 2>sorts of common tasks, from platform to detection, text manipulation,

429
00:19:02.880 --> 00:19:04.079
<v Speaker 2>interactive prompts.

430
00:19:04.279 --> 00:19:07.240
<v Speaker 1>So it's like having a whole team of expert scriptwriters

431
00:19:07.240 --> 00:19:08.039
<v Speaker 1>at my disposal.

432
00:19:08.119 --> 00:19:08.960
<v Speaker 2>That's right. That's right.

433
00:19:09.039 --> 00:19:11.519
<v Speaker 1>That's really cool. So I can use those functions both

434
00:19:11.559 --> 00:19:13.359
<v Speaker 1>from the command line and within my scripts.

435
00:19:13.400 --> 00:19:15.480
<v Speaker 2>That's right. Gives you a lot of flexibility.

436
00:19:15.759 --> 00:19:19.000
<v Speaker 1>Wow. Okay, we've covered a lot we have. We've covered

437
00:19:19.240 --> 00:19:23.200
<v Speaker 1>advanced scripting techniques, We've looked at external tools. One thing

438
00:19:23.200 --> 00:19:25.720
<v Speaker 1>we haven't talked about, though, is how do you actually

439
00:19:25.759 --> 00:19:27.920
<v Speaker 1>write these scripts? Ah?

440
00:19:28.039 --> 00:19:31.559
<v Speaker 2>Yes, so what tools are we actually using?

441
00:19:31.920 --> 00:19:34.319
<v Speaker 1>Yeah? Are we just using a plain text editor? Is

442
00:19:34.359 --> 00:19:35.680
<v Speaker 1>there anything more specialized?

443
00:19:36.000 --> 00:19:39.799
<v Speaker 2>Yeah? So choosing the right text editor can really boost

444
00:19:39.920 --> 00:19:41.279
<v Speaker 2>that scripting productivity.

445
00:19:41.519 --> 00:19:41.799
<v Speaker 1>Okay.

446
00:19:41.839 --> 00:19:45.480
<v Speaker 2>The book dedicates a whole chapter to exploring various text

447
00:19:45.640 --> 00:19:50.519
<v Speaker 2>editors like Vim, Emacs, Nano, k Write, Kate, get it.

448
00:19:50.880 --> 00:19:51.839
<v Speaker 1>Wow. That's a lot.

449
00:19:52.119 --> 00:19:54.039
<v Speaker 2>Yeah, quite a lineup, right.

450
00:19:54.359 --> 00:19:57.720
<v Speaker 1>Are there any standouts? What would you recommend for someone

451
00:19:57.839 --> 00:19:58.720
<v Speaker 1>just starting out?

452
00:19:59.480 --> 00:20:03.200
<v Speaker 2>Well, really depends on personal preference, learning style.

453
00:20:03.920 --> 00:20:04.160
<v Speaker 1>You know.

454
00:20:04.319 --> 00:20:07.720
<v Speaker 2>Vim is renowned for its power and efficiency, but it

455
00:20:07.759 --> 00:20:09.279
<v Speaker 2>does have a steep learning curve.

456
00:20:09.359 --> 00:20:10.799
<v Speaker 1>I've heard it's a blessing and a curse.

457
00:20:11.279 --> 00:20:13.359
<v Speaker 2>Yeah, that's a good way to put it. You know.

458
00:20:13.480 --> 00:20:18.160
<v Speaker 2>Emacs is another powerhouse known for its extensibility and customizability,

459
00:20:18.359 --> 00:20:19.799
<v Speaker 2>but it also has a learning curve.

460
00:20:19.920 --> 00:20:20.240
<v Speaker 1>Okay.

461
00:20:20.359 --> 00:20:23.799
<v Speaker 2>Nano is a more simple, user friendly editor, good for

462
00:20:23.880 --> 00:20:26.480
<v Speaker 2>quick edits, Okay, might be good for beginners.

463
00:20:26.640 --> 00:20:30.519
<v Speaker 1>So there's kind of an editor for everyone's right, every taste?

464
00:20:30.640 --> 00:20:31.759
<v Speaker 2>Yeah, for every taste.

465
00:20:31.839 --> 00:20:35.319
<v Speaker 1>Now, what about those graphical editors like k write and

466
00:20:35.440 --> 00:20:37.240
<v Speaker 1>kate and get it.

467
00:20:37.720 --> 00:20:43.160
<v Speaker 2>So those offer a more visual and intuitive editing experience. Okay,

468
00:20:43.200 --> 00:20:47.279
<v Speaker 2>you know they features like syntax highlighting, autocompletion, even built

469
00:20:47.319 --> 00:20:50.359
<v Speaker 2>in terminal emulators, which can be super helpful for testing

470
00:20:50.400 --> 00:20:51.880
<v Speaker 2>your scripts as you write them.

471
00:20:52.000 --> 00:20:55.000
<v Speaker 1>Oh okay, Yeah, so we've got our scripting environment set up. Okay,

472
00:20:55.079 --> 00:20:59.160
<v Speaker 1>we've learned how to write scripts, make them interactive, automate tasks,

473
00:20:59.400 --> 00:21:02.559
<v Speaker 1>and even organize our code with functions. That's right. What

474
00:21:02.640 --> 00:21:05.279
<v Speaker 1>else is there? What other powerful techniques are out there?

475
00:21:05.359 --> 00:21:07.400
<v Speaker 2>Well? Next app will delve into the world of data

476
00:21:07.440 --> 00:21:11.839
<v Speaker 2>manipulation and unlock those secrets of Said and Gok and

477
00:21:11.920 --> 00:21:15.200
<v Speaker 2>discover the power of regular expressions.

478
00:21:14.880 --> 00:21:17.519
<v Speaker 1>Set in gowk. Those sound like characters from a sci

479
00:21:17.519 --> 00:21:18.039
<v Speaker 1>fi movie.

480
00:21:18.079 --> 00:21:18.759
<v Speaker 2>Ah, yeah, they do.

481
00:21:19.160 --> 00:21:20.079
<v Speaker 1>What are we getting into?

482
00:21:20.200 --> 00:21:22.599
<v Speaker 2>Don't worry, They're not as intimidating as they sound. Okay,

483
00:21:22.720 --> 00:21:25.759
<v Speaker 2>you know Said and Gok are powerful text processing tools

484
00:21:25.759 --> 00:21:31.319
<v Speaker 2>that can transform, filter, and analyze data with incredible speed

485
00:21:31.400 --> 00:21:32.079
<v Speaker 2>and precision.

486
00:21:32.279 --> 00:21:34.319
<v Speaker 1>All right, I'm ready to hear more about these SET

487
00:21:34.319 --> 00:21:38.119
<v Speaker 1>and GOCK tools. So these SET and GOCK tools tell

488
00:21:38.160 --> 00:21:38.519
<v Speaker 1>me more.

489
00:21:39.079 --> 00:21:42.440
<v Speaker 2>Yeah. So SAID stands for stream editor, okay, and it's

490
00:21:42.480 --> 00:21:46.480
<v Speaker 2>all about working on streams of text, processing data line

491
00:21:46.480 --> 00:21:49.319
<v Speaker 2>by line. So imagine you have a massive log file

492
00:21:50.039 --> 00:21:53.119
<v Speaker 2>or a databased stump. Instead of loading the whole thing

493
00:21:53.160 --> 00:21:57.079
<v Speaker 2>into memory, right, said, lets you process it efficiently one

494
00:21:57.119 --> 00:21:57.920
<v Speaker 2>line at a time.

495
00:21:58.079 --> 00:21:58.559
<v Speaker 1>Oh okay.

496
00:21:58.680 --> 00:22:02.599
<v Speaker 2>You can make changes, you can extract information, even transform

497
00:22:02.640 --> 00:22:03.880
<v Speaker 2>the entire structure.

498
00:22:04.000 --> 00:22:07.279
<v Speaker 1>It's like a specialized assembly line for text. Exactly each

499
00:22:07.359 --> 00:22:09.279
<v Speaker 1>line is going through getting modified.

500
00:22:09.359 --> 00:22:09.759
<v Speaker 2>That's right.

501
00:22:09.880 --> 00:22:10.240
<v Speaker 1>Okay.

502
00:22:10.400 --> 00:22:13.880
<v Speaker 2>And one of the keys to Said's power is using

503
00:22:13.920 --> 00:22:15.000
<v Speaker 2>regular expressions.

504
00:22:15.079 --> 00:22:16.359
<v Speaker 1>Yeah, regular expressions.

505
00:22:16.400 --> 00:22:18.359
<v Speaker 2>You know, they might seem a bit cryptic at first.

506
00:22:18.720 --> 00:22:20.240
<v Speaker 1>Yeah, they can be a little intimidating.

507
00:22:20.359 --> 00:22:22.200
<v Speaker 2>Yeah, I know. But they're like a secret language for

508
00:22:22.240 --> 00:22:26.680
<v Speaker 2>pattern matching. Okay, you can specify some really complex search criteria.

509
00:22:26.799 --> 00:22:29.480
<v Speaker 1>I've seen them used, but I've never really understood how

510
00:22:29.480 --> 00:22:29.880
<v Speaker 1>they work.

511
00:22:30.079 --> 00:22:33.119
<v Speaker 2>Yeah, I understand. So the book it breaks them down

512
00:22:33.160 --> 00:22:39.359
<v Speaker 2>into manageable pieces, explaining like those anchor characters, character classes, quantifiers,

513
00:22:39.720 --> 00:22:42.480
<v Speaker 2>and even how to combine these to create really specific

514
00:22:42.680 --> 00:22:43.640
<v Speaker 2>matching rules.

515
00:22:44.240 --> 00:22:47.400
<v Speaker 1>So it's like learning a new language for working with data.

516
00:22:47.759 --> 00:22:48.720
<v Speaker 2>That's a great way to put it.

517
00:22:48.799 --> 00:22:51.720
<v Speaker 1>Okay, can you give me example of how said and

518
00:22:51.839 --> 00:22:54.000
<v Speaker 1>regular expressions actually work together.

519
00:22:54.119 --> 00:22:56.880
<v Speaker 2>Sure. Let's say you have a file with a list

520
00:22:56.920 --> 00:22:59.319
<v Speaker 2>of names. Okay, each one's on a separate line, like

521
00:22:59.400 --> 00:23:02.839
<v Speaker 2>John Smith, Jane Do, and so on, and you want

522
00:23:02.839 --> 00:23:06.240
<v Speaker 2>to just extract the last names from those lines. Okay, Well,

523
00:23:06.319 --> 00:23:09.200
<v Speaker 2>with said and a simple regular expression, you can do

524
00:23:09.240 --> 00:23:12.279
<v Speaker 2>that instantly. Oh wow, The regular expression would target the

525
00:23:12.319 --> 00:23:15.200
<v Speaker 2>space between the first and last name. Oky, Intel said

526
00:23:15.440 --> 00:23:18.680
<v Speaker 2>to only output the part of the line after the space.

527
00:23:19.240 --> 00:23:23.759
<v Speaker 1>Wow. Okay, yeah, so that's said. What about gok How

528
00:23:23.839 --> 00:23:24.720
<v Speaker 1>is that different? So?

529
00:23:24.799 --> 00:23:27.759
<v Speaker 2>Gawk is another powerhouse, but it's more like a programming

530
00:23:27.839 --> 00:23:31.799
<v Speaker 2>language specifically designed for data manipulation, so it goes beyond

531
00:23:31.880 --> 00:23:37.559
<v Speaker 2>that simple text manipulation. Allows you to perform calculations, use variables,

532
00:23:37.720 --> 00:23:42.039
<v Speaker 2>even structure your code with conditional statements and loops, just

533
00:23:42.039 --> 00:23:44.240
<v Speaker 2>like you would in a traditional programming language.

534
00:23:44.279 --> 00:23:46.200
<v Speaker 1>It's like having a mini programming environment.

535
00:23:46.359 --> 00:23:47.640
<v Speaker 2>Yeah, that's a great way to put it.

536
00:23:47.759 --> 00:23:50.839
<v Speaker 1>Specifically designed for working with data exactly.

537
00:23:51.079 --> 00:23:54.799
<v Speaker 2>And it's great for tasks like extracting specific fields from

538
00:23:54.799 --> 00:23:59.240
<v Speaker 2>a file okay, cleaning up MESSI data, generating reports, even

539
00:23:59.279 --> 00:24:01.680
<v Speaker 2>performing base statistical analysis.

540
00:24:01.839 --> 00:24:04.319
<v Speaker 1>So GAWK is definitely something I need to learn more about.

541
00:24:04.400 --> 00:24:06.920
<v Speaker 2>Yeah, it's a good one. And it also uses regular

542
00:24:06.960 --> 00:24:10.480
<v Speaker 2>expressions for pattern matching just like I said, but GAWK

543
00:24:10.680 --> 00:24:14.799
<v Speaker 2>offers some additional features and flexibility. What well, you can

544
00:24:14.960 --> 00:24:18.799
<v Speaker 2>use variables within your regular expressions, making them even more dynamic.

545
00:24:18.839 --> 00:24:21.480
<v Speaker 1>It's like a turbocharged regular expression engine it is.

546
00:24:21.680 --> 00:24:24.160
<v Speaker 2>Yeah, and it also has a rich set of built

547
00:24:24.200 --> 00:24:29.519
<v Speaker 2>in functions for working with strings, arrays, okay, mathematical operations.

548
00:24:29.559 --> 00:24:31.559
<v Speaker 1>There's so much power in the command line.

549
00:24:31.680 --> 00:24:33.880
<v Speaker 2>Yeah, it's really amazing all the things you can do.

550
00:24:34.119 --> 00:24:37.000
<v Speaker 1>It's really making me think differently about what's possible.

551
00:24:37.119 --> 00:24:37.839
<v Speaker 2>That's right. Now.

552
00:24:37.880 --> 00:24:40.680
<v Speaker 1>We talked about the Bash shell earlier, but there are

553
00:24:40.720 --> 00:24:42.880
<v Speaker 1>some alternative shells that we could use too.

554
00:24:42.880 --> 00:24:46.599
<v Speaker 2>Right, yes, yes, So each shell has its own philosophy,

555
00:24:46.680 --> 00:24:49.839
<v Speaker 2>features and little quirks. Okay, So this book talks about

556
00:24:49.839 --> 00:24:54.839
<v Speaker 2>the dash shell. It's a lightweight alternative to Bash, often

557
00:24:55.400 --> 00:24:59.599
<v Speaker 2>the default shell in Debian based distributions like a Buntu

558
00:25:00.319 --> 00:25:02.799
<v Speaker 2>because it's so efficient, but it might not have all

559
00:25:02.839 --> 00:25:04.079
<v Speaker 2>those advanced features.

560
00:25:04.160 --> 00:25:06.079
<v Speaker 1>So it's kind of like if Bash is a Swiss

561
00:25:06.160 --> 00:25:09.119
<v Speaker 1>army knife, Dash is like a simple pocket knife.

562
00:25:09.200 --> 00:25:10.960
<v Speaker 2>There you go, that's a great way to put it.

563
00:25:11.000 --> 00:25:11.960
<v Speaker 1>Just gets the job done.

564
00:25:12.039 --> 00:25:12.480
<v Speaker 2>That's right.

565
00:25:12.720 --> 00:25:14.400
<v Speaker 1>Now, what about this shell?

566
00:25:14.559 --> 00:25:18.200
<v Speaker 2>Ah, you know, that's like the luxury Sedan of shells, okay,

567
00:25:18.599 --> 00:25:22.759
<v Speaker 2>known for its power customization features like plug and support

568
00:25:23.319 --> 00:25:24.839
<v Speaker 2>advanced command line editing.

569
00:25:25.160 --> 00:25:27.240
<v Speaker 1>So it's for power users who really want to customize

570
00:25:27.279 --> 00:25:28.559
<v Speaker 1>everything exactly. Wow.

571
00:25:28.880 --> 00:25:31.400
<v Speaker 2>Yeah. So the book does a great job of highlighting

572
00:25:31.400 --> 00:25:35.079
<v Speaker 2>the strength and weaknesses of each shell, helps you choose

573
00:25:35.119 --> 00:25:36.359
<v Speaker 2>the best one for your needs.

574
00:25:37.119 --> 00:25:41.359
<v Speaker 1>So we've covered file management, shell scripting, data manipulation, even

575
00:25:41.400 --> 00:25:44.279
<v Speaker 1>alternative shells. Is there anything else in this book that

576
00:25:44.319 --> 00:25:44.839
<v Speaker 1>we need to know?

577
00:25:45.359 --> 00:25:48.799
<v Speaker 2>Well, there's one more essential aspect of scripting, especially when

578
00:25:48.839 --> 00:25:53.279
<v Speaker 2>collaborating or working on complex projects, and that's version control.

579
00:25:53.480 --> 00:25:54.079
<v Speaker 1>Version control.

580
00:25:54.200 --> 00:25:55.519
<v Speaker 2>Yeah, version control.

581
00:25:55.240 --> 00:25:55.599
<v Speaker 1>I've heard that.

582
00:25:56.039 --> 00:25:58.839
<v Speaker 2>Yeah. It's super important for scripts, okay, just like it

583
00:25:58.880 --> 00:26:01.519
<v Speaker 2>is for code. It helps you keep track of changes

584
00:26:01.519 --> 00:26:05.039
<v Speaker 2>to your scripts okay, allows you to revert to previous versions,

585
00:26:05.640 --> 00:26:09.240
<v Speaker 2>compare different versions, even merge changes from multiple people.

586
00:26:09.440 --> 00:26:11.799
<v Speaker 1>So it's like a time machine for your scripts exactly.

587
00:26:12.079 --> 00:26:15.440
<v Speaker 2>So, GET is the most popular version control system out there,

588
00:26:16.079 --> 00:26:22.200
<v Speaker 2>and the book gives a great overview of those core concepts. Repositories, commits, branches, Okay,

589
00:26:22.359 --> 00:26:25.839
<v Speaker 2>the importance of using a remote repository.

590
00:26:25.039 --> 00:26:27.119
<v Speaker 1>For backup, so if I met something up, I can

591
00:26:27.160 --> 00:26:30.839
<v Speaker 1>always go back. Wow. This has been an incredible journey

592
00:26:30.880 --> 00:26:32.599
<v Speaker 1>into the world of the Linux command line.

593
00:26:32.640 --> 00:26:33.279
<v Speaker 2>It has.

594
00:26:33.559 --> 00:26:36.359
<v Speaker 1>We went from the basics all the way to Wow,

595
00:26:36.440 --> 00:26:39.240
<v Speaker 1>some really advanced stuff he did. What really stood out

596
00:26:39.240 --> 00:26:42.160
<v Speaker 1>to me was the versatility and power of the command line.

597
00:26:42.319 --> 00:26:43.119
<v Speaker 2>Yeah, for sure.

598
00:26:43.240 --> 00:26:45.759
<v Speaker 1>It's not just about typing in commands. It's about understanding

599
00:26:45.799 --> 00:26:48.720
<v Speaker 1>how the system works, that's right, and being able to

600
00:26:48.759 --> 00:26:50.759
<v Speaker 1>create your own tools and automate tasks.

601
00:26:50.960 --> 00:26:54.440
<v Speaker 2>It really is about taking control of your computing environment.

602
00:26:54.680 --> 00:26:57.839
<v Speaker 1>Yeah, making it work for you exactly. So for everyone

603
00:26:57.960 --> 00:27:00.440
<v Speaker 1>listening out there, how can you use these tools and

604
00:27:00.480 --> 00:27:03.880
<v Speaker 1>scripting skills to automate tasks in your own work or

605
00:27:03.880 --> 00:27:04.559
<v Speaker 1>personal life.

606
00:27:04.759 --> 00:27:07.200
<v Speaker 2>Yeah, that's the real challenge, right, and the real fun.

607
00:27:07.720 --> 00:27:10.519
<v Speaker 2>It's about taking these skills and applying them to those

608
00:27:10.599 --> 00:27:11.640
<v Speaker 2>real world problems.

609
00:27:11.960 --> 00:27:14.119
<v Speaker 1>What repetitive tasks can you eliminate?

610
00:27:14.240 --> 00:27:14.680
<v Speaker 2>That's right?

611
00:27:14.759 --> 00:27:17.799
<v Speaker 1>What data can you process more efficiently? What tools can

612
00:27:17.839 --> 00:27:19.519
<v Speaker 1>you create to make your life easier?

613
00:27:19.680 --> 00:27:20.119
<v Speaker 2>Exactly?

614
00:27:20.160 --> 00:27:23.279
<v Speaker 1>This has been a great deep dive. Remember, mastering the

615
00:27:23.319 --> 00:27:27.559
<v Speaker 1>panline is a journey. Keep experimenting, keep learning, keep pushing

616
00:27:27.559 --> 00:27:30.279
<v Speaker 1>those boundaries, and you'll be amazed at what you can achieve.

617
00:27:30.640 --> 00:27:32.799
<v Speaker 2>And who knows, maybe one day you'll even teach your

618
00:27:32.799 --> 00:27:36.279
<v Speaker 2>computer to dance. All right, thanks for joining us, Thanks

619
00:27:36.279 --> 00:27:37.119
<v Speaker 2>for having me, Mack
