Answers:
>不是命令,而是文件描述符重定向。这意味着外壳程序会解析此分配,将其从命令行中删除,并更改启动它的新进程的环境。新进程不会注意到命令行的这一部分。这就是为什么您可以将其放置在任何地方的原因:在开始,结束或之间。
查找REDIRECTION块man bash。
为了追加到现有文件,您需要使用>>。
>是重定向运算符。注意>,除非设置了noclobber,否则使用重定向到常规文件将覆盖已经存在的文件。>>将追加到文件末尾。
noclobber已设置(重击),它不会覆盖。
noclobber不只是一种bashism。它是POSIX
正如其他人回答的那样,>它不是命令,而是重定向操作符。但是,术语“重定向运算符”不是专门指>,而是许多不同的可能的重定向运算符。该dash手册页列出了以下的重定向操作符:
< > >| << >> <& >& <<- <>
我不确定每个名称是否都有有效的个人名称。也许,如果您翻阅一些旧的Shell手册,您会发现一些有趣的东西。此来源(正确或不正确)当然可以命名其中一些:
> - 'output redirection operator'
< - 'input redirection operator'
>> - 'output append operator'
但是也:
2> - 'standard error redirection operator'
但是,我不认为这是真的,因为从2技术上讲,这是一个参数,而不是运算符的一部分。
快速参考(如果您不认识上述任何一种):
> - redirect output stream to a file, eg >somefile (for stdout) or 2>somefile
>| - as above but overwrite the file even if the noclobber shell option is set
>> - append output stream to file
< - redirect input stream from file, n defaults to 0 for stdin
<> - open file for reading and writing on stdin
>& - redirect output stream to another stream (eg >&1) or close with - (eg 2>&-)
<< - here document - see http://en.wikipedia.org/wiki/Here_document
<<- - here document with leading tabs removed.
在bash你里面还有:
<<< - here string, a one line here file. Eg <<<"foo bar"
<<-删除前导制表符和空格吗?
> 将输出重定向到文件(或设备),覆盖那里已经存在的任何内容
>> 将输出重定向到文件(或设备),并附加到文件或设备上已存在的任何内容
< 将数据从文件(或设备)定向到程序或设备
<< 这里文件
<<是此处文档
noclobber设置了该选项,>|则将覆盖并允许破坏文件。