Remove double char occurences

I have a file with random characters where every time a char occurs twice, one occurrence must be removed.

Eg.

asjkdhaSSd

Must become:

asjkdhaSd

Anybody has a SED script in mind to do it?

With a sed that conforms to the standards, it is pretty simple:

sed 's/\(.\)\1/\1/g' file

With GNU sed :

sed --posix 's/\(.\)\1/\1/g' file

might work.

1 Like