命令 | 解释 | 示例 |
command > file | 输出重定向到file | echo hello > test.txt |
command < file | 输入重定向到file | cat < test.txt |
command >> file | 将输出通过追加的方式重定向到file | echo hi >> test.txt |
n > file | 将文件描述符为n的文件重定向到file | exec 3>test.txt |
n >> file | 将文件描述符为n的文件以追加的方式重定向到file | exec 3>>test.txt |
n >& m | 将输出文件n和m合并 | cat n>&m |
n <& m | 将输入文件n和m合并 | wc -l 2<&1 <test.txt |
<< tag | 将开始标记tag和结束标记tag之间的内容作为输入 | wc -l <<EOF |
名词 | 解释 | 操作符 |
0 | 标准输入(stdin) | <,<< |
1 | 标准输出(stdout) | >,>>,1>,1>> |
2 | 标准错误输出(stderr) | 2>,2>> |
2>&1含义:将标准错误输出重定向到标准输出。注意:>&是一个整体,分开就不是这个意思了。 |