Eduard Gamonal
Eduard Gamonal

Reputation: 8031

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?

Upvotes: 0

Views: 79

Answers (1)

Chris Seymour
Chris Seymour

Reputation: 85815

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.

Upvotes: 2

Related Questions