Replace with sed until match in a line

sedtext processing

I have to replace all "." characters before the "=" character in every line in a file.
The lines are like this:

one.two.three=something
four.five=1
six.seven=127.0.0.1
eight.nine.ten.eleven=somethingwerylong
twelve=something.with.dots

and so on…

The result must be like this:

onetwothree=something
fourfive=1
sixseven=127.0.0.1
eightnineteneleven=somethingwerylong
twelve=something.with.dots

Best Answer

sed -e :1 -e 's/^\([^=]*\)\./\1/; t1'

t1 branches to the 1 label if there has been a successful s command. That's one of the ways to implement conditional loops in sed.

Or:

awk -F = -v OFS== '{gsub(/\./, "", $1); print}'
Related Question