bash 数据流重定向 > >> 2> 2>> < <<

1. 标准输出(将正确数据输出)

">" :以覆盖的模式将输出定向到某文件下(先清空,再输出)

">>":以累加的方式 将输出定向到某文件下

2. 标准错误输出(将错误数据输出)

"2>"

"2>>"

3. 标准输入

举个例子,创建文件语句如下:

root@dev:~/yxmfiles# cat > test

在屏幕输入内容后,按ctrl+D退出完成。如果想从文件中读取数据而非从屏幕读取:

root@dev:~/yxmfiles# cat > test2 < test

即从test读取信息输出到test2里

4. 标准输入不用ctrl+d来结束的方法

root@dev:~/yxmfiles# cat > catfile << "eof"
> i
> love
> cs
> eof
root@dev:~/yxmfiles#

"<<"的意思就是说以什么样的字符结束输入

原文地址:https://www.cnblogs.com/yxmfighting/p/8184540.html