Most shells restrict the name of functions to contain only characters that don't need to be quoted, which excludes >
.
Even in the few shells that allow >
as a function name (I only know of zsh), defining a function called >
would only have an effect if you called >
as a command (which would require quoting it, i.e. running \>
or ">"
or '>'
). It would not change how redirection works.
None of the usual shells have a way to configure what happens if some subsequent part of the script performs a redirection. If you need that kind of things, a shell is not nearly a flexible enough language. But there's probably a better way to solve whatever problem you're trying to solve — and quite possibly one that can be solved in a shell script.
>
? – jofel Mar 25 '15 at 10:20bash
accepts only one argument after>
so why do you use$1
and$2
? The answer to your actually question is probably actually no, but it is not yet clear what you really want to achieve. – jofel Mar 25 '15 at 10:31>
is not a solution, if you explain what you are trying to do, we might be able to help you find another way. – terdon Mar 25 '15 at 12:52