ChinaUnix.net
相关文章推荐:

unix sed怎么修改文件内容

sed -i 's,^name=x,name=$name1,g' $wenjian/newname 目的:修改文件newname的参数name=x为name=其他值,这个其他值是由别的参数$name1来提供的。 比如name1=china。 最终目的是将name=china。 求正确写法!

by jww3000 - Shell - 2009-04-23 10:59:59 阅读(1231) 回复(1)

相关讨论

文件内容如下: $req = { SessionID=>"::sas1.auth1::aQUSp2FxEPCxTXpGsmoU0T6C2Gf1S0uE", RequestID => $rid, ElementIDList => [10], ConditionType => 101, Severity => 5, #Timestamp => 1332317487, Description => "This is a test message added using eventAdd" #can be empty string #ParentAlarm => 1 }; 现在需要将"::sas1.auth1::aQUSp2FxEPCxTXpGsmoU0T6C2Gf1S0uE",修...

by IT农民工 - Shell - 2012-11-23 14:45:08 阅读(1583) 回复(6)

sed修改的处于缓存中的内容,这种操作是不会改变原文本的内容的,有什么好的方法可以实现修改硬盘上的文本内容, 想到的一个方法就是用中间文件过渡,然后用它去替换原文件。 请问还有其他方法吗,大家都是怎么实现这个的?

by jiangwen127 - Shell - 2009-06-08 21:48:16 阅读(2365) 回复(4)

文件内容如下: volume client type protocol/client option transport-type tcp option remote-host 10.10.101.94 option remote-port 6996 option remote-subvolume brick1 end-volume 怎么sed写一脚本把remote-host 后面的字符串 换成别的ip;然后文件保存。

by LunarBull - Shell - 2010-05-30 00:55:41 阅读(2971) 回复(10)

[code]#!/bin/bash base=100 t=100 for((i=1;i<51;i++));do echo $i num=`expr $base \* $i` echo $num sed -i "s/thrs = $t/thrs = $sum/g" t.rb echo "replace $t to $num" cp t.rb $num.log t=$num done[/code]初始化 t.rb的内容为 thrs = 100 为什么上面执行了50次,$num.log为空 而最后一次 t.rb thrs 这行的结果为 thrs =

by adastudy - Shell - 2010-06-18 22:17:24 阅读(2147) 回复(4)

sed -i '/^\[\]2014-07-03/d' *.log sed: illegal option -- i Usage: sed [-n] script [file...] sed [-n] [-e script]...[-f script_file]...[file...] ods_gj@ods-db2 $ -i 不能使用了,请问使用什么参数

by wmsok - Shell - 2014-07-16 17:01:53 阅读(3110) 回复(12)

想法很简单,查找一个文件 test,找到里头包含 ”System.Block”= 的 行, 然后如果= 后面是 NO ,则修改成YES,如果本来就是YES则不修改sed '/'System.Block='/s/YES/NO/g' test 这样屏幕显示的内容中是替换了,但是原文件没有替换,查看sed 参数也没有此相关内容, 我现在的做法是很原始,就是结果写入到另外的文件, 然后覆盖原文件,在删除那个临时的文件。 总觉得太傻了,,望各位高手能指点

by kentchoi - Shell - 2009-09-04 14:29:31 阅读(5357) 回复(2)
by rabbitkn - Shell - 2013-03-23 13:34:59 阅读(4726) 回复(4)

[code]uid = root [web] path = /opt/a/ comment = a ab =cd [test] path = /opt/a/ comment = b param = value [abc] path = /opt/a/ comment = c [def] path = /opt/a/ comment = d cba [/code]比如我想修test模块属性用sed如何实现

by love_net - Shell - 2011-07-15 15:21:02 阅读(4635) 回复(6)

想把一个文件里的abc 用123 代替并保存。应该怎么写? sed s/abc/123/g file1 > file1 , 这样会导致file 变为空文件。 就好像执行 ls -l > newfile一样,0字节的 newfile 也出现在newfile文件中。 难道只能到一个临时文件再改名吗?(sed s/abc/123/g file1 > file2; mv file2 file1) 有办法一条命令完成吗?

by IT业的民工 - Shell - 2004-09-20 04:18:23 阅读(3148) 回复(19)

我想修改test文件中的内容 在所有 name的行前加上# 然后在name1前增加一个新行,内容为name1=(test,test123) 如果不用-i 参数该如何实现,我写了一个但是出了错误,请大家帮忙看下 cat test name1=(login1,login1) name2=(login2,login2) name3=(login3,login3) sed '/name[0-9]*/s/^/#/g; /name1/i\ name1=(test,test123)' test > test.bak 报的错误如下 sed: Function /name1/i\ name1=(test,test123) cannot be parsed....

by bairb2008 - Shell - 2009-03-24 10:51:38 阅读(1525) 回复(5)