Now it's time to look at the last command, which is W.S., it is one of the last command, four text
processors that in our lectures that we are going to cover a W, C stands for word count and what exactly
it does to command reads either standard input or a list of files and generates a new line count, word
count and byte count.
So if you just run W.S. on a file, it will give you these three output.
Now let's get into our last machine.
And I have the first command, as you all know, is to check the version and to get the help.
So when I get to my Linux machine and again, I'm logged into the PUDI and you guys know what?
We have to run, you have to run as a username and a host name and which directory we are in.
And pretty much once we confirm perfectly you're the screen and now do a WC and I'm going to skip Origin.
I know all of you guys know this already by now.
These are the few options that it is it supports.
And then the one of the one of the most is used, one that I use as well.
And a lot of people use is minus L, which will cover in a few.
So now let's get into the next command, which is W.S. filename.
Let's clear the screen.
I'm going to go to my Seinfeld directory and in there I have my Seinfeld characters.
Let's cat out.
And these are the contents.
This is the content of the Seinfeld character as well.
Perfect.
Now, if I do, let's clear the screen again.
If I do see Seinfeld characters hit Enter, you're going to see it will tell me exactly what's inside,
meaning it has 17 lines, has 34 words and 236 bytes.
So if I wanted to know only the line numbers that inside a Seinfeld character, I could simply do W.S.
word count.
Or sometimes people refer to as Wakka Dash L and Seinfeld characters.
You're going to see it will give me only the number of lines.
That is 17.
Similarly, I could do either W or B to get the word count and the byte count.
So for the word I will see, it'll give me thirty four for the byte count.
I'll replace it would be.
Is it a by count, why is not giving me the information invalid option minus B for the bike count?
Hmm, that's new.
OK, let me check.
Why is that Dash Dashty help and we'll see are for the bikes is actually C c.
That's why it's so important for you to run W.S. Dash Dash helped to find out their right option or
what's the other one.
The big one man w c which will also give you a lot of information about that Pacific Command.
Anyway, my slide is showing minus B that is OK, you could ignore it.
I will go back and fix it later.
But for now, for this lecture we'll go continue with W, C minus C for bite size.
Also a lot of people confuse this with the minus C meaning characters.
It's not a characters, it's actually a bite size.
So the file name would be Seinfeld.
Sinovel usually use bytes and characters are somewhat similar.
Maybe a few.
Not exactly if you two or three numbers up and down.
But anyway, a focus on C minus C if you wanted to get the bite size.
All right.
The next come in.
I have the WC directory, which is not allowed.
So if you're trying to do the WC on a directory, so let's say inside of my Seinfeld directory, there's
no directory.
So I'll go one step back and do A minus L to see which directories are there.
And now I will do W.S. on Sindel Directorate enter.
It will say W.S. Seinfeld is a directory, so it's not going to give me any information that I'm looking
for regarding lines R word count or bytes.
Anyway, clear the screen.
Let's go to the next one and which is the Ls minus L command, which we will run and that will give
us the list of output.
Again, this is the command one.
Before we were talking about reading from the file.
Now this is reading from the output of a command.
So if you wanted to see how many files that you have, let's say your boss comes to you and says, hey,
listen, I need the list of files we have in this user home directory.
Give me that number.
You go in and you quickly run ls minus L, C, minus L, and you come back to him and or her and tell
tell your boss, hey, we got fifteen files.
All right.
C. is working perfectly here, and it is giving you the count of every line, but in fact, you do not
have 15 files or direct, you have 14 y because you see this total 280 here.
This is something that it is also counting.
So always remember when you do at Ellis minus L and C minus L, whatever the result that you get, always
minus it with one.
So, so now you could say that I have 14 files and directives all together.
What if I wanted to not only the list of directories in my in my home directory.
So to do that, you know, to list the directories, you have to run the command I think list minus
elde or else minus L d slash homes.
I absol.
OK, it is giving me.
All OK, so this is not the right.
Anyway, I will look it up, but what is the right command?
However, I could still use another trick.
See, that's what Linux is so powerful and you do at least mysel.
You notice that every directory starts with D.
So what I'm going to do is I'm going to do this myself and grep for a d r w because all of them, if
you notice, starts with D or wdr w so just get me all the directory.
So by default now I have all the directories anyway.
So now if I wanted to know how many directories I have hit up Baraki and do a C minus L, so it is telling
me that I have 11 directories now.
It is not giving me the total right here you notice because the total will only give you when you only
run.
Ls minus L as soon as you run Elsmere and pipe it, that total will go away and then you will just grab
Wadiya w because you only grumping for anything that starts with TRW and the total does not start with
TRW anyway.
As an, as an exercise for you, go ahead and find out the command of URLs minus L, D or whatever the
command is and find out which command will give you only the directory.
I use the grep.
It works for me.
Perfect.
But anyway there is I'm definitely sure there is a command and I'm sorry I didn't, I didn't know that.
Anyway, that's for you to find out.
So that's how you know the number of files in your directories and your home directory.
And then the last comment that you will run is to grab for keyword in, you know, file and then get
a list of it.
So I'll go back to my Seinfeld directory, InDesign file directly.
I have a file Seidenfeld, as everybody know.
So I'll Dukat Seinfeld and here I will grep for Seinfeld.
So Grupp sign Felde in my Seinfeld characters file and you notice there are three people with this last
name, Seinfeld.
Now if I won, if I had, let's say twenty or thirty or thousand of those name that match my criteria,
then how would I know how many were there?
So simply the pipe it c and myself selling will tell you there are three instances of your search criteria
works perfect.
I hope you understand now all the text processing commands.
I have explained it in very detail.
Please, please do try them with different options and different scenarios and see which ones works
for you and which ones give you more fun to work with.