Standard Stream Redirection
The standard streams are normally associated with the console. The command will print to the terminal, or will read input typed into the terminal. Stdin and stout can also be redirected to write to or read from a file.
Redirect standard input with <
$./mycode < params.txt
Redirect standard output with >
$ls –l > filelist.txt
If the file exists, >
will overwrite it. Append with >>
.
$cat file1 >> bigfile.csv
Redirection of standard error depends on the shell and is needed for only a few commands.
For bash
$make >& make.out
redirects both stdout and stderr from the make
command to make.out
.