0

Given a command like this:

command <inputfile> <outputfile>

And then called like this:

command FileA > FileC FileB

It takes A and B as input and outputs to C, but how can it parse the third argument, since the output redirection is between the arguments?

Mknsri
  • 3

1 Answers1

0

The shell parses the command-line, and sets up redirection. In this case, it sees > FileC, sets up the corresponding redirection, and removes those terms from the command: so what ends up being executed is

command FileA FileB

command itself never sees the > FileC part.

See What are the shell's control and redirection operators? for details on redirection in general.

Stephen Kitt
  • 434,908