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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.