yael
yael

Reputation: 2913

How to shutter the "#" characters in line to one "#" char by sed?

How to shutter the "#" characters to one "#" char by sed ?

From:

param=## ### ff ## e ##44

To:

param=# # ff # e #44

Upvotes: 0

Views: 57

Answers (2)

NeronLeVelu
NeronLeVelu

Reputation: 10039

posix version (for non GNU sed)

sed 's/#\{2,\}/#/g' YourFile

Upvotes: 0

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340261

One way to do it using extended regexps:

vinko@parrot:~$ echo "## ### ff ## e ##44" | sed -r s/#+/#/g
# # ff # e #44

With regular regexps:

vinko@parrot:~$ echo "## ### ff ## e ##44" | sed -e s/##*/#/g
# # ff # e #44

Only after the equal sign:

vinko@parrot:~$ echo "param=## ### ff ## e ##44" | sed s/=##*/=#/g
param=# ### ff ## e ##44

Upvotes: 1

Related Questions