文件内容如下: $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",修...
sed修改的处于缓存中的内容,这种操作是不会改变原文本的内容的,有什么好的方法可以实现修改硬盘上的文本内容, 想到的一个方法就是用中间文件过渡,然后用它去替换原文件。 请问还有其他方法吗,大家都是怎么实现这个的?
文件内容如下: 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;然后文件保存。
[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 =
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 不能使用了,请问使用什么参数
想法很简单,查找一个文件 test,找到里头包含 ”System.Block”= 的 行, 然后如果= 后面是 NO ,则修改成YES,如果本来就是YES则不修改, sed '/'System.Block='/s/YES/NO/g' test 这样屏幕显示的内容中是替换了,但是原文件没有替换,查看sed 参数也没有此相关内容, 我现在的做法是很原始,就是结果写入到另外的文件, 然后覆盖原文件,在删除那个临时的文件。 总觉得太傻了,,望各位高手能指点
配置文件:test.txt
[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如何实现
想把一个文件里的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) 有办法一条命令完成吗?
我想修改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....