2

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
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

1

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.

jlliagre
  • 61,204