Korn shell Tutorials :Data Redirection

Korn shell Tutorials :Data Redirection
General
Data redirection is done with the follwoing signs: > >> < <<. Every program has at least a
standardinput, standardoutput and standarderroroutput. All of these can be redirected.
Command Output to File
For writing into a new file or for overwriting a file do: command > file
For appending to a file do: command >> file
Standard Error Redirection
To redirect the error output of a command do: command 2> file
To discard the error alltogether do: command 2>/dev/null
To put the error to the same location as the normal output do: command 2>&1
File into Command
If a program needs a file for input over standard input do: command < file
Combine Input and Output Redirection
command < infile > outfile
command < infile > outfile 2>/dev/null
Commands into Program ( Here Document )
Every unix command can take it's commands from a text like listing with:
command EOF
input1
input2
input3
EOF
From eof to eof all is feeded into the above mentioned command.

No comments: