Linux Creating Files
2K views
Nov 28, 2024
Linux Creating Files
View Video Transcript
0:00
now into our previous video we have seen
0:02
how we can list a file and directory and
0:05
we have also seen without the columns
0:07
and details of files are there now here
0:10
in this particular video we are going to
0:11
see how we can create our own file and
0:14
which command we can use for creating
0:16
the firm so basically you have two
0:18
different commands very first cat come
0:21
on so cat command you can use if you
0:23
want to add some data into the file on
0:25
the time of creation the file itself so
0:28
cat command can be used cat space of
0:31
file name and automatically it will
0:33
prompt you through the next slide and
0:35
you can add the data into it and you can
0:37
store the file so for storing the file
0:40
you need to press control D key and you
0:43
can save your file which we are going to
0:45
see later same way you have patch file
0:48
or touch commands so touch commands
0:51
generally used for creating a blank or
0:54
empty file when you can add the data
0:57
into the file later on so this both
1:00
commands are used for creating the file
1:02
let us see how we can use it into the
1:04
tunnel so here I am going to create a
1:08
fur so as such we can see here we do not
1:11
have any file into this particular
1:13
directory that is a home directory of
1:15
your trainer user now I want to add a
1:19
file so first I'm going to add a file
1:22
with some content so if I want to create
1:25
a file I can give cat come on along with
1:29
the single redirection sign and here
1:31
I'll define the file name for example I
1:33
have to find a file name as five and one
1:36
a gentle add some text of it the cat
1:42
file command is to add data in the file
1:55
okay so I've added some line and now I
1:58
want to save the file so you can see
2:00
well I have defined the cat and greater
2:03
than sign and file name so it first
2:06
added me asked me to add our line so
2:09
I've already added a line and now I want
2:11
to save the file
2:12
so for saving of
2:13
I'll give ctrl + D so once you have done
2:18
with that it will save your file let us
2:21
check the file has been created or not
2:23
can you see the file is created can also
2:28
lose the file and check whether we have
2:29
created on same day or not so this is a
2:32
time at which I have created my file on
2:35
this date and this is the time of
2:37
creation and the permissions who has
2:42
created a file there is a trainer the
2:45
group is again neutrino created a file
2:48
file1 so this is the way you can use a
2:50
cat command to create a file same way
2:53
you can also use a touch command so I'm
2:57
just going to clear this terminal and
2:59
now we'll be giving the touch command to
3:01
create empty file so I'm going to define
3:04
file - and just hit enter now can you
3:07
see that a friends it is not asking me
3:09
for adding the text here or we do not
3:12
have to press anything to save the file
3:14
and spite the file has been created
3:16
correct so you can see if all two is
3:19
again created by the trainer itself
3:22
right at this particular time but I
3:25
haven't added anything into the file so
3:27
these are the two matters you can use
3:29
for creating a file if you want an empty
3:31
file use the touch command if you want
3:34
to create a file by you adding the data
3:36
simultaneously into it you can go for
3:39
the cat command so in the next video we
3:41
are going to see more about managing
3:43
your files
#Programming