免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1738 | 回复: 5
打印 上一主题 下一主题

问题请教 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-02-25 23:12 |只看该作者 |倒序浏览
在看《linux shell脚本攻略》,书上说 cmd 2>&1 output.txt和cmd &> output.txt功能一样,但是在ubuntu环境下,前面一个语句不能执行完成,后面一个能够执行完成。

这时咋回事??两个语句的功能到底一样不?

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
2 [报告]
发表于 2012-02-25 23:43 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2012-02-26 00:13 |只看该作者
2楼的,我的前面一个语句有错误?

论坛徽章:
0
4 [报告]
发表于 2012-02-26 00:21 |只看该作者
Redirecting Standard Output and Standard Error

This construct allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word.
There are two formats for redirecting standard output and standard error:

&>word
and
>&word
Of the two forms, the first is preferred. This is semantically equivalent to
>word 2>&1

man bash(1)

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
5 [报告]
发表于 2012-02-26 00:33 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
6 [报告]
发表于 2012-02-26 13:24 |只看该作者
a:  
    command &>$filename

b:
    command >$filename  2>&1

c:
    command 2>$filename  >&2
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP