码迷,mamicode.com
首页 > 其他好文 > 详细

file descriptor 0 1 2 一切皆文件 stdout stderr stdin

时间:2017-10-29 16:49:14      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:一个   app   描述符   ls -l   out   屏幕   stdout   error   create   

 

 

$>emtry_or_create_a_file.f

$ll>>append_a_file.f

 

 

standard output input error 

 

$ls -l /usr/bin >ok.txt  标准输出文件有内容 运行正确的结果信息

 

$ls -l /bin/usr 2 >ok.txt 标准输出文件有内容 运行错误信息

0 input

1 output

2 error  

$ls -l /bin/usr >emptry.txt 标准输出文件无内容  不会将结果输出  缺少文件描述符中的2

 

 

 

 

将标准输出和标准错误重定向到一个文件的2种办法

 

$ll /bin/usr >o.f 2>&1

$ll /bin/usr & > o.f

 

标准错误将重定向到屏幕

$ll /bin/usr 2>&1>o.f  

 

 

 

不希望的到输出

$ll /bin/usr 2 >/dev/null

 $x 2>/dev/null

file descriptor 0 1 2 一切皆文件 stdout stderr stdin

标签:一个   app   描述符   ls -l   out   屏幕   stdout   error   create   

原文地址:http://www.cnblogs.com/yuanjiangw/p/7750279.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!