[Autogenerated] Now, if you haven't come across this already,
we do have something called sd files.
These are input files where we can add expressions to ed from our input file.
Now, this can be great where we have multiple expressions.
We've already seen that we could use an enhanced regular expression
to delete both the commented and the empty lines.
But we could also write it as two separate expressions just
using a semicolon to separate those expressions.
So something like this is relatively simple to run through.
But if it became more complex, we could create a said file,
we could add our expressions to the said file.
So here we're deleting, then the empty lines here,
we're deleting the commented lines,
save the file and then execute set using the option minus F
and referencing our input file for the expression and then
the file that we want to edit.
So in this case,
the SSH D underscore config now becomes a good and simple way to
make the script a little bit more readable.
We can see what's happening line by line.
But its also as we start learning more about S C is going to be very
useful as we start getting more complex options,
let's take a look at something a little bit more complex.
Now,
if we take our SSH _____ configuration file and take a look at the settings that
we can implement to allow for us not to drop idle clients.
A couple of settings, we got to look for the client alive interval.
This is set in seconds and represents how often we send
packages to clients to keep them alive.
The second setting is the client to live count mac and its how many
intervals we can allow to pass without receiving a client response
before we decide to drop that client.
And when we look at our configuration file,
we might have the option where it is set in the
configuration value but to a wrong value or it may be in
the configuration file but commented out.
So we can look at making those changes in a set file.
We can go through and implement our sang here.
We're using the upper case e within the shebang to remind us that we
should be using an enhanced regular expression.
We can go through and look for the string, client, a live interval.
Now we're just looking for the string anywhere in the line,
we open up with our brace bracket, a block of code and then within the block,
we're looking to see well, OK.
Does the client to live interval appear at the beginning of the line?
But we're also putting a group around the client to live interval.
That means then that we can copy that and use it in those substitution text.
So we're looking for client to live interval followed by anything.
And then when we're looking at the replacement,
the slash one is our first group.
So that's going to be our client a live interval.
And it saves me having to write it out twice.
It's going to be set to 60 seconds.
We can then use the T for test and we can then specify, well, OK.
If we succeeded on this substitution, we can move ahead to the label count.
If we didn't succeed though, we can look at the next substitution here.
We're looking for the client a live interval anywhere on the line.
So it's just then just going be dot star,
we're replacing the complete line with client a live interval,
60.
Again, we can then specify that we're moving to the label count.
So if this succeeds,
we close off our block of code and then we define whatever we need within count,
which is going to be something similar, isn't it?
We won't put the whole code in here.
Once we've then finished,
we can go ahead and execute the said command referencing
our file against our SSH D configuration.
This is then going to allow us no matter whether the setting is
commented or whether it is there at the wrong value,
it is going to get changed.
Now, the best way to learn though is not by looking at the slides,
it's actually by doing so,
why don't we go out to our command line and see how we can implement this?