开发者

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

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

From:

p开发者_Python百科aram=## ### ff ## e ##44

To:

param=# # ff # e #44


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


posix version (for non GNU sed)

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜