Hello and welcome to command line
BASIX, this is Lennix file commands
three. I'm Christopher Haler.
Let's begin.
So we're learning objectives for
this video. We're going to learn
about the fine command and the group
command and understand how to pipe
into crêpe from the command line.
And these are very important as
well. So we're going to be able
to search through items and
find things that we're interested in
and pipes in through command so
we can look for
assessment.
What is true about the command?
Is it a it cannot search
A case and sensitive B,
it can be used to search in binary
files or see it cannot
use regular expressions.
The answer is, B, it can be
used to search in binary files.
This is very useful fact with
the GHURAYB command where we can
search through executables, these
binary files and
search for strings that are inside
of them. So we're going to have to
specify that very specifically
in order to search through.
But that's something we can learn
and look inside of the help or the
manual for in order to be able
to do that.
Grep can search case and sensitive.
That's the dash I
switch and it can
use regular expressions.
That's the the ar e
is a regular expression for
grep.
All right. So for the fine command
this is supposed to locate, except
there is no database, there's no
index for finding use.
So it's it's a lot slower
because it has to actually go
through everything inside the system
instead of referencing that
database.
But it is much more robust
than locate because it is searching
through everything at the time
you entered the command instead of
just relying on a
pre indexed database.
So on.
This may take longer.
It will search through everything
and then it looks through every part
of the system.
And the find is a little different
because we're going to type, find
and then the path you want to look
in and then the file name
and you need to make sure that you
use the name
and then the name of the file you're
looking for. Otherwise it
won't be able to find it very
easily.
So let's take a look at an example
now.
Let's say I want to find the
microgram file, but
I don't know where it is.
So we're going to start at the root
of the operating system
and type find and
then slash the root.
And I'm going to do Dasch name
and my program.
So this will look starting at
the root of the operating system for
any file that has the name
my program.
And as you can see, it took a little
longer than the key command,
and it did find the
file in the folder we're
in right now and then also found it
in the drag and drop folder.
So we had another program labeled my
program as well.
And you could see we had permission
denied entering this other folder as
well. And if you find
yourself getting a lot of permission
denied trying find it.
Just go ahead, type sudo
and run that same command
under pseudo so you can as re-route
and then you shouldn't have that
problem.
All right, now we have grippe, so
it is very important to understand,
because it is so useful to be able
to search through files and folders
and either find files
or look through and get
these matches for things you need to
find.
It's very expensive and it uses
pattern based searching that
is with the new regular
expression grep stands for.
And so a regular expression
is very kind of tricky
and difficult to understand.
But when you get to a point where
you're using the shell to search for
patterns and you know exactly what
you need to find, I highly recommend
understanding and taking the time to
learn regular expressions so you
can become much more effective at
at the show.
So this also works really
well when piped to other commands
because Greb takes that standard
input and it can use it very
fluidly in order to give you
your output.
So grep is very useful command
that you need to be very familiar
with in order to search through and
find things that you're going to use
in order to learn how to integrate.
So just like we were learning,
grep is such a useful command to
search through things.
And we can use the pipe command,
which we've used a handful of times
already in this course, and
take that output and put
it straight into the grep command
so we can look into exactly
what we need.
And then on top of that, we
can take the output from the command
typed into grep and run that
into another pipe into less
that way. If we get a lot of output
from the grep command, we can take
our time scrolling up and scrolling
down in the output so
we can see exactly what we have
on our terminal and take our time
reading through it.
And if you haven't figured out
already, there are countless ways to
pipe multiple commands together.
So it's important to feel
comfortable with using all these
commands at once so you can
create a very effective
flow at the command line.
So let's show a quick demonstration
of that. So I'm inside of
my Linux machine and
let's say I want to go into this
Frankenstein folder and A do
seed capital F because
it is case sensitive to
enter.
And now I have this Frankenstein
data, so
I'm going to create
Frankenstein because this will put
it out into the
terminal, the terminal window on
once.
So I want to prep for
Frankenstein itself.
You make sure I spelled this
correctly, all
right, and if you enter,
you'll see it didn't find anything.
This is because in the
text file, Frankenstein is always
capitalized.
Now, if we take a look at the help
or rip that to
help, which is what we should
be using when we use a command
so we could take our time, learn
about it, we can see that
the dash
ignores the case.
So is case insensitive?
So let's say let's bring this back
and let's say we want to look
through and find Frankenstein.
So we're going to do Dashti
and check it out.
We have all sorts of different
Frankensteins because they're all
capitalized and it was ignored
in case with the dashi.
Now, there was a lot of
text put out at once.
So let's use the up arrow,
bring our previous command back, and
we'll add another pipe and add
less.
And as you can see, we have
it starting at the top
and we can take our time going down,
going back up and find
all of the output that we got.
So this is very useful and
you should be able to be very
comfortable with it at the command
line or
post assessment, which which
is used to search through binary
files.
It A dash A,
B, dash B,
C dash C
or D dash dash binary.
The answer is a dash A.
This is used to search through
binary files with grep.
And even though we didn't
demonstrate it, it's a very useful
technique that you need to be able
to use in order to search through
these files and try and find
keywords.
So the dash b dash
dash binary are not valid
switches for searching through
binary files.
And I highly recommend looking
through the manual or looking
through the help for grep because
it is such an important command to
feel comfortable with.
So in this video we're trying to
find command line, the group command
and then we understood at a pipe
into crêpe and then pipe out of
our grep results as well.
So I hope to see you in the next
video.