Tuesday, January 17, 2017

Input Output redirection



Standard output is the result of a script or a command displayed on the console.

Below are few examples to see how to redirect the standard output.


1)      
Redirect the output of a valid command.

It will redirect the output of the command to the redirection file. Here the command is ls /tmp/tempwork and the redirection file is output-redirection.  If >> is used for redirection, it will append the result of the command to redirection file. This all happen only when the command is valid


2)      
Redirect the output of a non-valid command.

It will redirect the output of the command to the redirection file. Here the command is ls /etc/passwdasd and the redirection file is output-redirection.  If 2>> is used for redirection, it will append the result of the command to redirection file. This all happen only when the command is not valid and if the command is valid it will result the output on the console




3)       Redirect the output of a non-valid command.



When & is used it will redirect the standard output and standard error.

No comments:

Post a Comment