Results 1 to 5 of 5
I have the following string 1524)), I want to get rid of the parentheses. I have tried SED and AWK without success.
The last I tried was: echo "1526))" | ...
- 07-01-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 3
delete parentheses in a string
I have the following string 1524)), I want to get rid of the parentheses. I have tried SED and AWK without success.
The last I tried was: echo "1526))" | sed 's/\)).*$//'
Any suggestions will be appreciated.
- 07-01-2010 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Try ths:
echo "1526))" | sed 's/)*$//'
- 07-02-2010 #3Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
welcome to the forum
here's another way
echo "1526))" | tr -d \)the sun is new every day (heraclitus)
- 07-03-2010 #4
It depends on exactly what the circumstances are. tpl's solution is much simpler, and it will remove all ')'s from the string. This is great if it's what you want. However, if you want to only remove two ')'s from the end of a string, you need something more like lomcevak's solution (it's a bit different because I prefer to be explicit):
Code:tanya:~ alex$ echo '1526))' | sed -e 's/))$//' 1526
DISTRO=Arch
Registered Linux User #388732
- 07-06-2010 #5Just Joined!
- Join Date
- Jul 2010
- Posts
- 3
Thank you so much for your help!
"Press on: nothing in the world can take the place of perseverance. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent." ~ Calvin Coolidge


Reply With Quote