The next command that is also a remainder from the past is Set the stream editor.
This is also a command that stems from the early days of UNIX where you didn't have full screen editors yet.
So AWK is useful for filtering text and printing specific values only.
And set is a stream editor and it allows you to edit files in non visual mode.
Let me show you a couple of examples.
So first is set minus n 5p etc pairs wd which is
printing the fifth line from etc wd set also has substitute options.
So set minus I s/anna slash anna for instance and let's make
that global on regex and we don't see anything. But if I
use cat on regex, then what do we see? Well, it found
na one time, but it has converted it into uppercase.
What I like a lot about SED is that it allows you to delete a line from a
text file without even opening the text cell. And that's convenient if some utility is complaining about an
error on line, whatever. So then you can use set I E for edit 2D, which is the
line addressing with the Command. So delete line 2 from regex and now line 2 is deleted.
Now let me do something funny and that is echo hello, great. Then
1 config and 2 conf and 3 conf and let's use a small
structure that is used in shell scripting for I in conf that is
iterating over all files that have a name that ends in conf.
Then the semicolon is opening the second part of this
command do set minus I substitute hello to buy.
And let's not make that a global operation this time and do it on $I.
And then we close it using the DOM.
And what do we see? Well, if we go to3.conf we can see that it now contains buy.
But maybe you are not very impressed with that because you could also use
set I substitute buy to duy, which is Dutch for buy on starconf.
I mean, what is the additional value of the 4i in range
here? If you can also address the file names by wildcard.
And that's something that you will often encounter while working with Linux. Sometimes you have found a fantastic solution
with this advanced command, only to find out that it can be done also in a lot easier way,
but a much simpler command. But hey, that's the flexibility and also the power of this fantastic operating system.