echo输出到stderr
来源:互联网 发布:c语言代码在线 编辑:程序博客网 时间:2024/06/06 03:40
On the unix command line, each command can print to stdout (standard output) or stderr (standard error). By convention, error messages go to stderr, and normal messages go to stdout. You usually connect stdout to the stdin (standard input) of another process. Having a long pipe of commands and this stderr/stdout convention means that the error messages from one command don't go polluting the input to the next command. It also means that you can see the error messages of the commands, since stderr is shown on your terminal (if they were printed to stdout, then you would not see the error messages, since they would be sent to the input of another command).
When writing your own little scripts, it's a good idea to print your error messages to stderr. The usual way to print in a bash script is to use the echo
shell builtin command. You can "echo" to stderr like this:
echo "Your error message here" >&2
This is a normal echo (which goes to stdout), however the >&2
(which is shorthand for 1>&2
), means 'mix the stdout to the stderr'. 1
is stdout, and 2
is stderr here.
- echo输出到stderr
- python输出重定向到stderr
- echo 输出空行到文件
- gdb重定向stdout和stderr输出到调试窗口
- echo输出多行内容到文件
- Linux 技巧:重定向 stderr 和 stdout 输出到 gdb 窗口
- Android中如何将原生程序向stdout和stderr的输出重定向到logcat
- Linux 技巧:重定向 stderr 和 stdout 输出到 gdb 窗口
- Linux重定向:将标准输出stdout和标准错误stderr重定向到一个文件
- Linux 技巧:重定向 stderr 和 stdout 输出到 gdb 窗口
- Golang把所有包括底层类库,输出到stderr的内容, 重新定向到一个日志文件里面?
- 重定位stderr到文件
- Linux 技巧:重定向 stderr 和 stdout 输出到 gdb 窗口 挺不错 特别是里面的call调用
- 尝试将Python程序用管道命令输出到cd时报错 - sys.excepthook is missing lost sys.stderr
- echo输出彩色字符
- echo 输出中文
- echo输出图片
- 001.php输出echo
- js对象笔记(1)
- easyUI中的datagrid
- TIME_WAIT是什么?
- 使用YUM安装官方发布的MySQL数据库
- hashTable的学习
- echo输出到stderr
- HTML 框架标记(3) iframe与frameset的区别
- Lua 创建“类”及使用LUA“类”
- protobuf的基本配置
- Android Sensor 架构深入剖析
- Effective C++读书笔记之四:确定对象被使用前已先被初始化
- 什么是多态?为什么用多态?有什么好处?
- Being a Good Boy in Spring Festival(尼姆博弈)
- 杭电 2095