Redirection in Linux | Input redirection, Output redirection,Error redirection

Redirection it is very important in the Linux environment. When you run the particular command you will get the output in the shell prompt. you can redirect into the file. In these view it has three redirection



Input Output Error
Symbol < > 2>
Numerical 0 1 2
File Descriptor &0 &1 &1

Sample Example with Input Output Redirection.
./configure >> output_log 2>> error_log
make 2>&1 | tee file_name
2> Error Redirection
&1 Output File descript
script >> output ( only display the output)
script 2&>> output (display execute command + output)

Output Redirection
It is used lot of application in the Linux side.
When admin like to monitor the user activity he can use this command.
It will store the output command to the file
Output redirection symbol: >
Example:
Syntax
Command >filename
[studentwebsite@localhost ~]$ ls -l >file1
[studentwebsite@localhost ~]$ vi file1
if you open the file1 it will show the output of the command ls -l

When ever you run these command once again. it will delete the pervious command output and store current command output(overwrite).if you like to
do add new output to the old output (don't overwrite).
Do like that.
[studentwebsite@localhost ~]$ ls -l >>file1


Input Redirection
Input redirection it is normally not used. but you can known
you can open the file just cat file name.
It will store file to the command
Input redirection symbol :<

Error redirection
If your command it has any error the you can use this error redirection.
It will store this error to that file
Symbol:
2>
Example:
[studentwebsite@localhost ~]$ addus kumar 2>file1
[studentwebsite@localhost ~]$ vi file1
addus it is not command so it will through error message these error message store the error report the file 1

Post a Comment

0 Comments