1 00:00:06,599 --> 00:00:11,070 The next command that is also a remainder from the past is Set the stream editor. 2 00:00:11,869 --> 00:00:18,170 This is also a command that stems from the early days of UNIX where you didn't have full screen editors yet. 3 00:00:19,149 --> 00:00:23,079 So AWK is useful for filtering text and printing specific values only. 4 00:00:23,679 --> 00:00:28,410 And set is a stream editor and it allows you to edit files in non visual mode. 5 00:00:29,890 --> 00:00:32,210 Let me show you a couple of examples. 6 00:00:33,929 --> 00:00:40,651 So first is set minus n 5p etc pairs wd which is 7 00:00:40,651 --> 00:00:47,373 printing the fifth line from etc wd set also has substitute options. 8 00:00:47,373 --> 00:00:54,094 So set minus I s/anna slash anna for instance and let's make 9 00:00:54,094 --> 00:01:00,816 that global on regex and we don't see anything. But if I 10 00:01:00,816 --> 00:01:07,538 use cat on regex, then what do we see? Well, it found 11 00:01:07,538 --> 00:01:14,259 na one time, but it has converted it into uppercase. 12 00:01:14,799 --> 00:01:21,432 What I like a lot about SED is that it allows you to delete a line from a 13 00:01:21,432 --> 00:01:28,064 text file without even opening the text cell. And that's convenient if some utility is complaining about an 14 00:01:28,064 --> 00:01:34,697 error on line, whatever. So then you can use set I E for edit 2D, which is the 15 00:01:34,697 --> 00:01:41,329 line addressing with the Command. So delete line 2 from regex and now line 2 is deleted. 16 00:01:42,629 --> 00:01:48,867 Now let me do something funny and that is echo hello, great. Then 17 00:01:48,867 --> 00:01:55,104 1 config and 2 conf and 3 conf and let's use a small 18 00:01:55,104 --> 00:02:01,342 structure that is used in shell scripting for I in conf that is 19 00:02:01,342 --> 00:02:07,579 iterating over all files that have a name that ends in conf. 20 00:02:08,199 --> 00:02:13,164 Then the semicolon is opening the second part of this 21 00:02:13,164 --> 00:02:18,129 command do set minus I substitute hello to buy. 22 00:02:19,169 --> 00:02:23,229 And let's not make that a global operation this time and do it on $I. 23 00:02:24,770 --> 00:02:27,750 And then we close it using the DOM. 24 00:02:28,590 --> 00:02:34,789 And what do we see? Well, if we go to3.conf we can see that it now contains buy. 25 00:02:35,629 --> 00:02:42,610 But maybe you are not very impressed with that because you could also use 26 00:02:42,610 --> 00:02:49,590 set I substitute buy to duy, which is Dutch for buy on starconf. 27 00:02:50,110 --> 00:02:53,870 I mean, what is the additional value of the 4i in range 28 00:02:53,870 --> 00:02:57,629 here? If you can also address the file names by wildcard. 29 00:02:58,199 --> 00:03:04,273 And that's something that you will often encounter while working with Linux. Sometimes you have found a fantastic solution 30 00:03:04,273 --> 00:03:10,346 with this advanced command, only to find out that it can be done also in a lot easier way, 31 00:03:10,346 --> 00:03:16,419 but a much simpler command. But hey, that's the flexibility and also the power of this fantastic operating system.