Find the answer to your Linux question:
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))" | ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    3

    Talking 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.

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    Try ths:

    echo "1526))" | sed 's/)*$//'

  3. #3
    tpl
    tpl is offline
    Linux 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)

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    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

  5. #5
    Just Joined!
    Join Date
    Jul 2010
    Posts
    3

    Thumbs up

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...