Shell中的重定向
理解Unix/Linux中标准的输入输出流中字母所代表的含义HandleNameDescription0stdinStandard input, Use to get input (keyboard)1stdoutStandard output, Use to write information (screen)2...
·
理解Unix/Linux中标准的输入输出流中字母所代表的含义
Handle | Name | Description |
---|---|---|
0 | stdin | Standard input, Use to get input (keyboard) |
1 | stdout | Standard output, Use to write information (screen) |
2 | stderr | Standard error, Use to write error message (screen) |
- > 标准输出重定向,与 1> 一样
- 2>&1 将标准错误输出重定向到标准输出
- > filename
示例
重定向标准错误输出到文件
$ program-name 2> error.log
$ command1 2> error.log
重定向标准输出和标准错误输出到文件
$ command-name &>file
或者
$ command > file-name 2>&1
不输出信息
$ command &> /dev/null
更多推荐
已为社区贡献1条内容
所有评论(0)