1752579 Members
3283 Online
108788 Solutions
New Discussion юеВ

simple sed I hope

 
SOLVED
Go to solution
Adam Noble
Super Advisor

simple sed I hope

Hi all,

If I have a string (106.9.33.22) how can I simply strip the brackets from the output!!

Cheers
4 REPLIES 4
Ian Lochray
Respected Contributor
Solution

Re: simple sed I hope

sed -e 's/(//' -e 's/)//'
Ralph Grothe
Honored Contributor

Re: simple sed I hope

If you don't care for parens at all,
then how about

tr -d '[()]'
Madness, thy name is system administration
Dennis Handly
Acclaimed Contributor

Re: simple sed I hope

Similar to Ian's solution, you could of course strip all parenthesis with one RE:
sed -e 's/[()]//' file
Hein van den Heuvel
Honored Contributor

Re: simple sed I hope

If the file were to contain any other parens, tehn you may want to limit your replace to those parens surrounding numbers and dots (ip addresses?).

sed -e 's/(\([0-9.]\+\))/\1/' file


Hein