I recently came across a shell command that looked like this: “> outfile < infile cat”, which appears to be functionally equivalent to “cat infile > outfile”. For that matter, the general form seems to be “> outfile < infile command arg1 … argN” becomes “command arg1 … argN infile > outfile”.
Anyway, I was wondering if anyone could elaborate on how the leading “>” achieves this effect, and if there are any practical uses for it.
The “Bash Reference Manual” says the following about the redirection operators:
So the following commands are all equivalent:
Though I’d guess that the first is most common form.
Note that the relative order of redirections is significant, so if you’re redirecting one file descriptor to another, for example, the following would be different: