File display commands, this lesson covers about all the commands that are used to display the content
of our file.
You could view the file by doing a manual tr but.
And you could.
How can you view inside of the file the first commander Hulkower is the cat, which views the entire
content of a file, regardless whether it's one page or two page, more command or less command.
Both are the same, but more views the content of our file one page at a time, whereas less command
views the content of a page in reverse order.
But it also allows you to view one line at a time.
Then you have had, if you want to know a few lines at the top of a file, let's say four, five million
lines.
And you just want to view the first ten lines.
You could use head command, followed by the number of lines that you want to view, the same way the
tail works instead of the top of the file, it actually gets you the lines at the bottom of the file.
Again, if a file as well has a million lines and you put down minus, then it will give you the last
ten lines of a file.
Let's look at our Linux machine and see how we could use these commands.
OK, so let's clear this page out.
OK, the first thing I want you to do is copy.
The file called war log messages.
And copy it in your home directory.
You could do slash home your home directory, which would work, or you could also do copy the name
or the location of the entire file and follow by space and dot.
Dot means at this location where I am, you hit enter and now you do list minus L tr you hit enter and
you will see at the bottom right here, it shows that you have this file which is one two nine three
three eight bytes long.
By the way, you could view you could copy this file only if you are route.
So when you do, who am I.
You are route and you remember how you will become route.
Let's say if you exit out of it and you do, who am I?
You are yourself.
And now you are going to copy oi log messages to your current location.
It's now going to allow you.
So you have to be rude to become rude as you space dash but in the password.
And now you are in route, so go to your home directory, the user's home directly, which is your home
territory, and then you will see here this has this message file that you copied from the log and the
reason you were not able to copy it, because you see her only route, which is the user, the owner
of the file who is route is allowed to read and write to this file the rest of.
People, which is group, has no right for anything and so on, the others have no right or read right
to do anything.
Let's go back to our comments that we would cover if I wanted to view the contents of this file called
messages.
The command to use is CAT.
Messages simple is that you hit enter, see, it has all those contents messages, basically this message,
this file has all your logging information of your system, anything that is going on with your system,
any services that are running, any error messages, warning messages coming in, the health of your
computer, everything is stored in this file.
We copied this file in our home directory just to cover the file display command lesson.
So do a clear and then Dukat and messages again and you see it has a bunch of lines, text lines in
it and we could view it through care but then we have to scroll up.
So another way that so we don't have to scroll up.
How do you do you do more messages, you hit enter and there you will see you will get one page at a
time of that file messages.
Here you'll see it says one percent at the bottom.
You hit spacebar to keep going down, keep going down.
You're going one page at a time.
And while you're going, it also telling you the percentage of the file you have read, you keep going
down.
And if you want to get your prompt back, what do you do?
You simply type kill.
So that's how you use the more common.
Now let's use the less command, less command space messages hit enter.
It does the same thing.
You hit the space bar, hit the space bar one page at a time.
Also, it will give you one line at a time to view it.
When you hit Jay in your keyboard, it will come one line at a time or you hit K, which is a go back
up.
You could also do up arrow key or down arrow key, whichever that you prefer.
OK, Upper Cordona or key, whichever you prefer.
So that's what less allows you to do.
Next one we have had if you do more and messages you see the first page of your file messages.
What if you wanted to see only the first two lines?
You don't care what's inside the file after the first line, then what do you do?
You do head minus two space, the name of the file of messages and you will see the first two lines
of the file.
Then you'll do tail minus two messages, this will give you the last two lines of the fall, which is
the last who is March?
Seven, eight, three, ten, you could do Cadigan to messages and we'll bring you down to the last
page and you can verify, yes, these were the last ones.
So to wrap up, we covered Cat Comment, which lists the contents of your file.
Regardless how many pages it has, it's just displays everything in one shot.
Moore gives you one page at a time.
Let's give you one page at a time in reverse order.
But also view lets you view one line at a time.
Head gives you the first lines depending on what you define and tell gives you the last lines, depending
where you have defined.
Now exit out of route account.
Find out which direction you are in.
And do it myself here and you will see there is a file called Jerry in there, let's do Cat and Jerry
and you will see two lines and Jerry file the first line, says Jerry Seinfeld, the main character.
And the second line shows us the date and time of file, not the file, but an output or a text message,
whatever that is.
If I just wanted to view the first line of the file, I don't care.
The second line, what I would do is head minus one, Jerry.
And it would give me.
The first first line of the fire, what if I wanted to give you the last line, I don't care.
The first one that says I was the main character, I just wanted to know this line.
I will do till my one, Jerry, and give me the last line, so this is how her until work.