丢弃的输出(Discard the output)(过滤的输出)

Sometimes you will need to execute a command, but you don't want the output displayed to the screen. In such cases you can discard the output by redirecting it to the file /dev/null:

$ command > /dev/null

Here command is the name of the command you want to execute. The file /dev/null is a special file that automatically discards all its input.

To discard both output of a command and its error output, use standard redirection to redirect STDERR to STDOUT:

$ command > /dev/null 2>&1

Here 2 represents STDERR and 1 represents STDOUT. You can display a message on to STDERR by redirecting STDIN into STDERR as follows:

$ echo message 1>&2

Redirection Commands:

Following is the complete list of commands which you can use for redirection:

CommandDescription
pgm > fileOutput of pgm is redirected to file
pgm < fileProgram pgm reads its input from file.
pgm >> fileOutput of pgm is appended to file.
n > fileOutput from stream with descriptor n redirected to file.
n >> fileOutput from stream with descriptor n appended to file.
n >& mMerge output from stream n with stream m.
n <& mMerge input from stream n with stream m.
<< tagStandard input comes from here through next tag at start of line.
|Takes output from one program, or process, and sends it to another.



                                                                                                                        Name:Xr

                                                                                                                        Date:2014-06-01 17:01


转载于:https://my.oschina.net/Xiao629/blog/271489

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值