[英]sed/awk edit one line
I have to edit a line in place in a jad file. 我必须在jad文件中编辑一行。
MIDlet-Version: 0.5.38
should become MIDlet-Version: 0538
MIDlet-Version: 0.5.38
应该成为MIDlet-Version: 0538
I'm having trouble finding the line in the file. 我在文件中找到该行时遇到问题。 If I had the line already, I'd do:
如果我已经有了这条线,我会这样做:
echo 'MIDlet-Version: 0.5.38' | sed s/\\.//g
I tried several variations of: 我尝试了几种变体:
sed -i 's/\(MIDlet-Version: \)\\.//replace/g' myfile.jad
can somebody tell me what's wrong and how to do it properly? 谁能告诉我什么是错的以及如何正确地做到这一点?
You want: 你要:
sed -i '/MIDlet-Version: /{s/\.//g}' file.jad
This will remove all the periods from file.jad
only on lines containing MIDlet-Version:
and store the changes back to file.jad
. 这将仅在包含
MIDlet-Version:
行上从file.jad
删除所有句点,并将更改存储回file.jad
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.