bla*_*arg 41 shell io-redirection terminology
我试图找到如何将一些文本传递到文件而不覆盖已经使用该>命令的内容,但我意识到我不知道它叫什么。搜索右箭头或右 V 形或更多命令没有显示任何内容。我一直只是把它叫做pass to。
Hau*_*ing 56
>不是命令而是文件描述符重定向。这意味着 shell 会解析此分配,将其从命令行中删除并更改启动它的新进程的环境。新进程不会注意到命令行的这部分。这就是为什么你可以把它放在任何地方的原因:在开头、结尾或中间。
在 中寻找REDIRECTION块man bash。
为了附加到现有文件,您需要使用>>.
正如其他人所回答的那样,>不是命令,而是重定向运算符。但是,术语“重定向运算符”并不是专门指代>,而是指许多不同的可能的重定向运算符。该dash手册页列出了以下的重定向操作符:
< > >| << >> <& >& <<- <>
Run Code Online (Sandbox Code Playgroud)
我不确定每个人都有一个有效的个人名称。也许如果你翻阅一些旧的 shell 手册,你会发现一些有趣的东西。这个来源,无论正确或不正确,肯定会命名其中的一些:
> - 'output redirection operator'
< - 'input redirection operator'
>> - 'output append operator'
Run Code Online (Sandbox Code Playgroud)
但是也:
2> - 'standard error redirection operator'
Run Code Online (Sandbox Code Playgroud)
但是我不认为这真的是正确的,因为从2技术上讲它是一个参数而不是操作符的一部分。
快速参考(如果您不认识上述任何一个):
< > >| << >> <& >& <<- <>
Run Code Online (Sandbox Code Playgroud)
在bash你还有:
> - 'output redirection operator'
< - 'input redirection operator'
>> - 'output append operator'
Run Code Online (Sandbox Code Playgroud)