Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove double dots from a string and not the single dot using shell script

Tags:

linux

shell

I want to remove double dot from a string but not the single dot using shell script.

example string: a..b.c expected output: ab.c

I tried tr -d ".." but its removing all the dots. I tried tr -d "\.\." then also same result "abc".

Any suggestions would be appreciated.

like image 518
Nikita Avatar asked Apr 12 '26 03:04

Nikita


1 Answers

You can replace multiple dots with none:

sed -E 's/\.\.+//g'
like image 68
clemens Avatar answered Apr 14 '26 01:04

clemens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!