- All right to start with,
we need to delete the fifth line.
So, let me first you still minus five all users.
I like simple solutions
and here we can see the simple solution.
Oops. This is the last five line.
I don't wanna see the last five lines.
I want to see the first five lines.
So that will be Bob Belle.
So next I'm using SED, minus I to interactively write
to the target file minus E
for the edit command, five D to delete line number five
from the file users.
And if I use my hat again
then we can see that Bob Belle has been deleted.
So what is next?
Next is use Bob, in a pipe to filter the first column
out of the results of the command PS AUX.
In order to understand that we need
to have a look at PS AUX.
There we go.
These columns are, are formatted pretty nicely.
So PS AUX pipe AWK, let's just check
print dollar one and see what it is doing.
That's pretty successful.
Many commands that are about filtering are using spaces
as a default field separator.
You only use another field separator.
You can specify that, depending
on how to use the command minus
uppercase F for AWK that is.
But in this case, it was really simple because it's a space
the space, which is used as a separator.
The third task was to use, GREP
to show the names of all files
in (indistinct) that have lines
starting with the text route.
So I need SUDO for complete elite access.
Grep.
what am I going to GREP?
Well, lines starting with that's carrot.
So lines starting with ROOT in ETC star.
Oh, and I need a GREP option as well.
GREP minus L.
Hey, about the position of the option.
I know Linux is flexible.
It should work putting the option
at the, at the end of the line as well.
But if it's getting more complex, like in GREP where
you are using a regular expression.
Personally, I like putting the options directly
after the GREP command, then you do your regular expression
and then you do your file globbing pattern that makes it
easier for yourself to understand what is going on.
And shall we also, as a precaution, use two greater than
DEV, NULL so that we don't see any error messages at all.
And there we go.
These are the lines that we were looking for.
And if you want to verify that really, that is the case
just remove the minus L and you can see behind the name
of the file, how exactly the line was starting.
Okay, the next assignment is to
show all lines from all files
and users that have at least three letters N.
How are we going to do that?
Well, by using GREP with this repetition operator
and the repetition operator is going to be N followed
by slash, curly brace, three slash, curly brace,
single quote, users.
And there we go.
That's a match for three letters N.
And finally, we use GREP to find all files
that contain string, and I
at the end of the line, that's an easy one.
SUDO, GREP, minus R, ANNA dollar.
And you know what,
let's just do it on the current directory.
You get the idea that you can do this
on the entire route file system as well.
And we don't, of course we don't
because I just changed my users file.
Okay, so I need to, to use ECHO, HELLO, ANNA,
greater than greater than to users.
We have seen users,
we have seen single greater then,
which is redirecting the output.
This is a double greater then
which is bending the line to the end of the file.
And now if I read this again and let me,
let me get rid of the error messages.
Then we can see that users is a match.
And that is what you needed to do for this lab.