Hello, everyone, and welcome to the lecture of Cut Command, which is part of the text process that
commands what is a cut.
A cut command is a command line utility that allows you to cut parts of lines from specified floors
or pipe data and print the result to standard output.
It can be used to cut parts of a line, but the limiter bite position and characters and the commands
that we are going to learn are as follows.
So there are the first command that you can run is cut filename again.
Do not run cut with just a file name because it's not going to work.
You have to specify the option.
So I will log in to my Linux machine and I this time I'm going to log in and through my PUDI session
right here, I have my Linux machine and if you want to log into the putty session, you have to log
in to your console run if config command, get your IP address, which is one I to one 61 to 62 and
put into the putty and then you could log in through the putty.
But if you do not have this IP address, then you go to the Oracle Box network setting and you change
the network setting to Bridgid adapter and then it will allows you to get this IP address anyway.
So now the first command will use is cut and the filename and individual name are we going to use.
I have logged in as myself and I am in my Linux machine and which directory I'm in.
I'm in a home directory.
In my home directory.
I have a directory called Seinfeld.
I'll go into the Seinfeld directory.
Inside of that directory I have a file name, Seinfeld characters, and this is the file that I am going
to use for this cut lecture.
Then you do Cat on Seinfeld characters.
You are going to see the list or all the lines inside of the Seinfeld characters.
And these are the actual names of all the characters inside of the Seinfeld show.
I don't want you to focus on at the Seinfeld show itself, but I just want you to focus on the content
of this file.
If you do not have this Seinfeld characters file, please create it right now.
Pause this video and you should the files should have this content inside of your file, Seinfeld characters
anyway.
So let's assume that you do have this file and you do have exactly all that content inside of this file.
Now, the first thing is you do cut Seinfeld.
And as I said, you can run cut without any option.
It will give you the error message.
Then the next command that you should run is the cut that Worsham.
So cut, dash, dash version.
And it will give you the version right now, I'm running the version 82 to your version is probably
new or the older.
It does not matter which version you have.
The cut functionality is the same.
Also, you could do cut, dash, dash, help to find information about each option that it has to offer.
You can also do man cut to find detailed information about the command or utility cut and you could
go down by pressing the spacebar and hit cue to get out of it.
The next command I wanted to show you is if you wanted to get the first character or the first letter
of the file Seidenfeld characters.
So let's say if you have Seinfeld characters file, let's carry it out and you're going to see that
if you want to only get this first letter of every line, then you were on the command cut minus C one
and the file name, which is signed by the characters.
And it will give you the list of all the first letters in every line.
Then the next command will run is what if you want to pick and choose the characters?
So let's do Cat Seinfeld again.
And let's say if you want to first letter, then the third letter and then the fifth letter and then
the eighth letter, then you could do that by simply doing cut minus C one or three or five or seven,
whichever characters that you want to pick and choose and specify the file name.
And in this case it actually has pulled all those letters and jotted down together as one word.
Then next one is a list, a range of characters.
So what if you wanted to list the range of character, meaning as do Cat Seinfeld again and you wanted
to list the first character all the way through the fifth character, then you could do by simply doing
cut it's minus C sorry, minus C one through five or through three.
Whichever the ranges you wanted to specify, you had to enter and you will see, you will get the output.
Exactly.
That was show only five letters.
Next one is list specific, a range of characters.
What if you want to as cats and what if you want to do right here, one, two, three and then a six
to eight.
So from here to here.
So it is as easy as we have done earlier to cut my see one, two, three, then you put comma six through
eight or six through nine, depending on your requirement, you hit enter and you will see that it is
giving you the first three letters and then the six to eight letters.
The next example that we have is we could also get the list or output by the bite size.
So if you do catch Seinfeld, all of these letters are actually equivalent to the bites as well.
So Bite pretty much works as a characters as well or the letters.
So if you do cut minus B one through three and Seinfeld, you will see its output is pretty much similar
or exactly.
I would say like the minus C one through three.
Anyway, the bite might change on a certain spaces.
So just be careful what you wanted to use.
Then the next one is what if you wanted to get a list of columns of a file by specifying the delimiter.
So what is the limit?
So let's take an example of ETSI password file.
So I want you to look at Azzi password file hit enter.
And in this file you will notice that this is the file by the way is used when you create a user in
Lennix.
This file is the one that manages all the users or keep record of all the users.
So that is something we will learn later anyway.
So in this file, if you notice, there are columns and these columns are divided by this little colon's.
So you see this X and right after X has this colon and then this column colon and column.
So let's say I'm not going to use a column, I will use field.
So it would be easier to understand.
So colon and field.
Colon and field.
So what if you want to get a field by specifying the delimiter?
And in this in this case, the delimiter for you would be colon.
So if you want to do cut minus D and you specify Delimiter with.
Colon minus F and you specify the, uh, the field is six, then the name of the file, which is Seinfeld,
you will see I'm sorry, not Seinfeld, uh, etsi password.
That's the password.
Then you will see it is giving you the sixth feel.
That is right after the colon.
There's Dukat Azzi password again.
Then I could explain.
You see the first is this second is this third.
Fourth, fifth, sixth.
And this is what is grabbing for you, so in my case, if I have my user account, I have all this is
my first field.
Second, third, fourth.
5TH and 6th, so this is my home directory, so 6th column is actually my home directory, so it is
pulling that home directory.
You could also use the delimiter on many different symbols as well.
It's not only Kullen.
If this file was has a field and separated by, let's say, comma, then you could use just like this
comma, or if it was separated by, let's say, questionmark, then you would put questionmark anyway.
So Colon then let's say if you want to pull the sixth and seventh field then you could just specify
six to seven and it'll give you the two fields.
Next one is again, I already covered that.
OK, and then the last one I have is the cut file not only works on the file itself, it also works
on an output of what?
Of a command.
So let's say if you are in your home directory.
Home I have and you do as mad as hell, you'll see the list of all the files and directories.
What if you wanted to get only the this these three bits?
This three bets actually are the permissions of the file, which is owned by the user.
So if you wanted to get only that, then you will do less mysel, then cut minus C two through four.
Right.
So it will be two, three and four.
It enter and you will see it as only giving you that output.
So that's how the cut command a cut utility works.
I have given you many examples.
You should try it and try a different way to to it, to a different files or to different output.
And it will be a lot of fun to work with it.
If you have any questions, please do send me a message.
And I hope this lecture worthwhile in the cut.
Come in.