I want to redirect stdin
and stdout
and stderr
at the same time in bash
, is this how it's done:
someProgram < stdinFile.txt > stdoutFile.txt 2> stderrFile.txt
I want to redirect stdin
and stdout
and stderr
at the same time in bash
, is this how it's done:
someProgram < stdinFile.txt > stdoutFile.txt 2> stderrFile.txt
Yes, your syntax is correct although the following equivalent one is closer to what the shell actually does:
< stdinFile.txt > stdoutFile.txt 2> stderrFile.txt command arguments
The files used for redirection are open before the command is launched, and if there is a failure in this first step, the command is not launched.