Redirection
At times, you might need tò prevent error messages from being displayed on the screen, In
Linux, youcan change the default assignment of standard files. The process of changing the
assignment for the standard input, the standard output, and the standard error fle is known
as redirection.
Using redirection, input to a command can be taken from a file instead of the keyboard.
Similarly, the output of a command or error can be written to a file or printed instead of being
displayed on the screen. The three types of redirection are:
" Input
Output
" Error
Input Redirection
Youcan redirect the input from a file instead of typing the commands by using the keyboard.
The symbol for redirecting the input is<.
The following example explains input redirection:
$ cat < testl <Enter)
Here, the < symbol implies input redirection from the file testl on the hard disk. The cat
command reads each line of the file testlas input and displays it on the screen.
Therefore, using input redirecion, you can specify that the standard input is received from a
disk file instead of the standard input file.
For clarity, you can also type the above command by using the file descriptor as follows:
$ cat 0< testl <Enter>
Here, Oindicates input redirection.
At times, you might need tò prevent error messages from being displayed on the screen, In
Linux, youcan change the default assignment of standard files. The process of changing the
assignment for the standard input, the standard output, and the standard error fle is known
as redirection.
Using redirection, input to a command can be taken from a file instead of the keyboard.
Similarly, the output of a command or error can be written to a file or printed instead of being
displayed on the screen. The three types of redirection are:
" Input
Output
" Error
Input Redirection
Youcan redirect the input from a file instead of typing the commands by using the keyboard.
The symbol for redirecting the input is<.
The following example explains input redirection:
$ cat < testl <Enter)
Here, the < symbol implies input redirection from the file testl on the hard disk. The cat
command reads each line of the file testlas input and displays it on the screen.
Therefore, using input redirecion, you can specify that the standard input is received from a
disk file instead of the standard input file.
For clarity, you can also type the above command by using the file descriptor as follows:
$ cat 0< testl <Enter>
Here, Oindicates input redirection.