I have to create the function in shell script, that function name must contain the special characters. like
>()
{
echo 1ドル 2ドル
}
Here my function name is >
, If its possible how can I give, Like above I tried that But it will through the error
2 Answers 2
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.
The >
has a special meaning in the shell, it's a redirection operator, see the manpage:
[n]> file Redirect standard output (or n) to file.
The name of a function can contain only letters (a-z or A-Z), digit (0-9) or the underscore character (_). Also is must not begin with a digit. (see Function Definition Command and Name)
You must log in to answer this question.
Explore related questions
See similar questions with these tags.
>
?bash
accepts only one argument after>
so why do you use1ドル
and2ドル
? The answer to your actually question is probably actually no, but it is not yet clear what you really want to achieve.>
is not a solution, if you explain what you are trying to do, we might be able to help you find another way.