简体   繁体   中英

sed/awk edit one line

I have to edit a line in place in a jad file.

MIDlet-Version: 0.5.38 should become 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM