免费注册 查看新帖 |

Chinaunix

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

[SCO UNIX] 奇怪的sed [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-08-12 02:04 |只看该作者 |倒序浏览
Haven't done much scripting lately.

OS: tru64unix V4.0G, Shell: csh
# which sed
/usr/bin/sed
# echo "a b" | sed 's/ /\t/'
atb
# echo "a b" | sed 's/ /\\\t'
a\tb

???
I am expecting a TAB between "a" and "b", not "atb" nor "a\tb", what am I doing wrong?
Seems sed won't recognize all escape sequences such as \n,\t,\r,\b ...
Anyone have comment on this? much appreciated.

论坛徽章:
0
2 [报告]
发表于 2004-08-12 05:28 |只看该作者

奇怪的sed

看样子\t不管用,直接输入TAB就可以了。

http://www.unixguide.net/unix/sedoneliner.shtml

USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have used
the expression '\t' to indicate a tab character (0x09) in the scripts.
However, most versions of sed do not recognize the '\t' abbreviation,
so when typing these scripts from the command line, you should press
the TAB key instead. '\t' is supported as a regular expression
metacharacter in awk, perl, and in a few implementations of sed.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP