tzimme
tzimme

Reputation: 45

How to move a Character (in sed?)

I got a csv-file with semicolons within some words instead of between eg: wor;d How can i recognize all semicolons between to characters and move them to the right until no semicolons are between 2 characters?

Upvotes: 0

Views: 728

Answers (1)

devnull
devnull

Reputation: 123608

The following might work for you:

sed -r 's/(\w);(\w+\b)/\1\2;/g' filename

If you want to save the changes to the file in-place, you can say:

sed -i -r 's/(\w);(\w+\b)/\1\2;/g' filename

If you have words like ;word that need to be modified to word;, you could say:

sed -r 's/(\w?);(\w+\b)/\1\2;/g' filename

Upvotes: 2

Related Questions