Linux - I O Redirection
2K views
Nov 28, 2024
Linux - I O Redirection
View Video Transcript
0:00
so in this video I am going to explain
0:02
you about IO redirection now this IO
0:05
means input and output redirection you
0:08
can redirect your input anywhere you can
0:10
all day direct your output anywhere into
0:12
any particular file or into a different
0:15
terminal so the same thing we are going
0:17
to see here now if I'm talking about an
0:19
input/output trade direction as as
0:22
discussed this contains a command or a
0:25
particular commands or any text of the
0:27
file we have we can move in from your
0:30
one terminal to the other terminal or we
0:33
can use the output of one data or the
0:35
one page from the other page as well so
0:38
we have two different three directions
0:41
into it called as an output redirection
0:43
and your input redirection output
0:45
redirection what it will do you have
0:47
already given a command once you get the
0:50
output of this command you can get this
0:52
output into a different file or you can
0:54
redirect into a different terminal or
0:56
into different commands so here we can
0:58
see the output from a command lon
1:00
normally intent for the standard output
1:02
can be easily diverted to a file instead
1:06
of getting it on the prompt itself same
1:09
way for D directing the file the output
1:11
file or output command into the other
1:14
particular file or the other command we
1:17
just need to use this greater than sign
1:20
so for example I have given one
1:22
particular command and I want the output
1:24
of this command to be saved in the file
1:26
I'll just use the greater than sign
1:29
after the command and post that a file
1:31
name and I need to store it same way we
1:34
also have input redirection for example
1:37
I have a blank file created and I want
1:40
some output of a particular command into
1:42
this blank file so we can also take the
1:45
input of a command into it so again the
1:48
input of a command can be redirected
1:49
from offer so there you need to use less
1:53
than sign to redirect the input so this
1:57
is a greater than sign we can use for
1:59
output redirection and less than sign we
2:01
can use for input redirection so let us
2:03
see how we can use this input and output
2:06
redirection in to our console so here we
2:10
are going to talk about input and output
2:11
redirection so our discuss
2:13
if suppose I have some common Ori I hit
2:16
some command it will give me output on
2:17
the same consolers I'm terminal now what
2:20
if I want to provide the output Somalia
2:22
domina what are we doing is I will be
2:25
giving the same command who and I'll use
2:27
the output tray direction so this output
2:30
of this particular file will be moved
2:32
into thee
2:34
users but this is how generally we give
2:37
the output tray direction now the output
2:39
has not shown on the terminal but
2:40
instead it is moved on the users far you
2:44
can see this is updated now one more
2:46
thing we would like to see here that is
2:48
if suppose I am moving in the other
2:49
terminal and I get to login with some
2:51
different user like I have logged in
2:53
with James
2:56
so ultimately what will happen
3:05
ultimately what is going to happen is
3:07
like the who come on will change right
3:09
is the who will have one more than free
3:11
that James is added on TTY zero and
3:14
whatever I want to append this entry now
3:17
what will happen if I use the same come
3:18
on and users who and users but will
3:25
replace the complete content so the
3:28
trainer entry what we have wretchedly
3:29
log it won't be it will be moved so if I
3:32
want to
3:34
redirect this output to the users but I
3:37
want to append the entries just you need
3:39
to give double greater-than sign that
3:41
means you just need to define the is
3:44
beer addiction signed over here which
3:45
will be appending the existing file just
3:48
hit enter and check for catch users you
3:53
can see you have both tea
3:56
you have both the entry first for entry
4:00
from the first file and then the second
4:02
for increase you have right so this is
4:06
what exactly how we can use the output
4:09
in a direction now what if I want to use
4:12
the input tray direction so input
4:14
reduction can be used for anybody who
4:17
are commands like if suppose I want to
4:19
check for all the particular user
4:20
entries which I have added I want to
4:22
check into the particular file and I
4:25
want that that I should get the word
4:28
count of those things so what I can do I
4:30
can use the input redirection sign and I
4:32
can go for
4:35
users so now what it has done it has
4:38
taken the output of this particular user
4:40
and has counted it and hits us provided
4:43
over here itself so you can see the
4:45
command is showing the
4:47
w seas or the NSA word count of this
4:50
particular user into it right so it will
4:53
show you the output over here so this is
4:56
called as an input redirection so your
4:58
command is taking input from the
5:00
particular well now for example I have
5:02
created a file that is touch file I have
5:05
created line with the name new and again
5:08
I give new
5:12
input the direction sign and
5:18
users so it's showing me c'mon not for
5:21
means anyway I can only use and
5:23
left-hand side t come on not the
5:26
particular fun name
5:27
but white versa vice versa into the
5:29
output interaction father when I put in
5:31
detention file we came to come on and
5:33
here we need to specify the file name
5:35
for example I want to check the users WC
5:41
and I want to put the output into the
5:42
file called as new file which I have
5:44
created taken check the cat command for
5:49
the new file
5:51
so this is the output so this is how we
5:54
generally really find the input tray
5:56
direction and your output reduction
5:57
commands and append the entries for it
6:00
now for example if I added morning trees
6:02
into the users I just move into the
6:10
need to move here itself directly
6:15
users and I moved into the users I'm
6:19
going to add some entries more entries
6:21
over here so I'm just here that's that's
6:26
all entries we have this is I've added
6:31
the number of words into this right so
6:33
I'm just going to save the same
6:36
and more out of it
6:40
now again what the file was containing
6:43
the new file was containing was this one
6:45
right now again I want to redirect the
6:47
output of your this file so what I'll do
6:50
I'll give the command WC and then the
6:54
file name users again redirected
7:00
check it check the content on this
7:03
particular file
7:05
it's a finding the values so this is how
7:08
generally we put the know the defection
7:10
signs we can also use the double
7:13
redirection sign so that we can append
7:15
existing file over here so into next row
7:18
section we are going to check up out the
7:20
administration parts how we can
7:22
administer it to complete users and
7:23
comments as well as your disk that's
7:26
what we actually we are going to see so
7:29
keep watching
#Internet & Telecom
#Programming