用sed脚本在input文件里的file:后追加一行 结果出错:./append.sed: line 6: /file:/iWe: 没有那个文件或

[复制链接]
查看11 | 回复1 | 2011-5-5 11:32:05 | 显示全部楼层 |阅读模式
[root@localhost~]#cd/home/o_user
[root@localhosto_user]#catinput被操作文件
ThisisaCertificateRequestfile:关键字
[email protected]
=================================================






CertificateSubject:
/o=Grid/OU=CA-seugrid1.edu.cn/Ou=seu.edu.cn/CN=globus
Theabovestringisknownasyourusercertificatesubject,andituniquelyidentifies
thisuser.$88
Toinstallthisusercertificate,pleasesavethise-mailmessageintothefollowingfile.
/home/globus/.globus/usercert.pem
[root@localhosto_user]#catappend.sed脚本内容
#关键字后插入文本的i命令
#!/bin/sed-f


/file:/i\\
Weinsertanewline.
[root@localhosto_user]#./append.sedinput调用脚本
./append.sed:line6:/file:/iWe:没有那个文件或目录错误信息
[root@localhosto_user]#
回复

使用道具 举报

千问 | 2011-5-5 11:32:05 | 显示全部楼层
Weinsertanewline.需要放在双引号里,表示是一个整体。
因为命令解释默认是以空格为命令分隔符的,这样插入的内容只有We,而空格后面的内容会被解释为sed的输入文件,所以报这个错。
--------------------------------------------------------------------------------
明白为什么你不行了,脚本第一行不能有注释。
第一行必须放#!/bin/sed-f
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行