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
  • 66,199
  • 35
  • 114
  • 250
user258258
  • 23
  • 1
  • 4

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
  • 60,319
  • 10
  • 115
  • 157