Hello everyone and welcome to this lesson.
So in this video we are going to see some
more commands that is helpful in your day to
day routine of using Linux operating
system.
So we have these files which have been created over
here. So let me show you
how we can use Touch command. So we
already know that using touch command. We
can make empty files. So let's say I type touch
XYZ so it is going to create empty
file, which is XY said now, let's suppose
I want to make 10 empty files.
So for that I cannot write Touch 1 touch 2
3 4 5 or let's suppose
I want to make 100 files. I cannot every time
write Touch 1 touch 2 touch 3
touch 100 to make 100 mp
files for that. You can simply use the command touch
curly braces and one dot
dot 10. So this will create the
10 empty files. Let me show you our 10
files created over here and you can
see these are the files which have been created over
here.
Now you can see over here. It did not
create one and two because it is already being
taken by these directories which
is one and two.
So let's do LS hyphen all and you
can see over here one is directory
2 is directory 3
4 5 6 7 8 9 and 10
are files.
File 1 and file 2 is again file and
this is a symbolic link which we have created
and XYZ again is
a file perfect. Let me clear the
screen.
Now we have already seen how to read a file for
that. We use the command cat and the file name.
So let's read the file which is file to and here it
says this is file too. Now if
you want to browse through a text file, you
can also do that simply use the command less. So
let's type less file two
and hit enter and you can see
this is file to and it is the end of the file perfect.
So let's say if you want to see the first
10 lines of a file so for
that you can use the command head and file too. Now,
there is only one line. That is the reason you're
able to see only one line. So let's quickly create some
lines into this file and let's say
This is first line.
Enter and let's let's simply type
some random words over here. And let's
say this is the last
line. Let's quickly save it.
And now we are going to use the command head.
file to
oops
Head file to and you can see these are the first
10 lines. This is the first line second third fourth
fifth. This is
an empty line, which is sixth this is
seventh eight nine. And this
is the last one which is the tenth line. Now if
you want to do the similarly from the
bottom, so if you want to read the last 10 lines, you
can use the command tail file to hit
enter and you can see this is the last line
which is the Ten line eight seven, six
five four three two one. So this
way you can read the top of the document as
well as the bottom of the document.
in case you want to read
more than 10 lines simply you can
type head hyphen and how many lines you
want to read. So let's say you want to read 12 lines. So
head - 12 and the
file name.
Here you can see this this command was head file
to and we could read the top 10
lines and it ended with SF. So
there should be two more lines 11th and
12th, which is DS and F. So this
way you can specify the number
of lines that you want to read with hyphen
and the number the count over
here.
Perfect.
Similarly you can do this with tail as well. So tail
hyphen 15 and the file
name. So the file name is file to hit enter
here. You saw we got a error because we
made a space over here. So let's Rectify
this.
And here you can see we're able to see the last 15 lines
now.
If you want to read a document in a PDF document
viewer type of mode simply you
can use the command which is more and the
file name here. You can see this looks
something like this and you
are able to read the file completely over
here. So I hope you guys understood.
Thank you.