Sed adding and stripping [ and ] - SCO

This is a discussion on Sed adding and stripping [ and ] - SCO ; Hello, I am being really dumb today. I can get perl to do it but I really need to get things working with sed. I have a script that is pasrsing input and what I get is [xxx.xxx.xxx.xxx] or [ip6-address] ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Sed adding and stripping [ and ]

  1. Sed adding and stripping [ and ]

    Hello,

    I am being really dumb today. I can get perl to do it but I really need
    to get things working with sed. I have a script that is pasrsing input
    and what I get is

    [xxx.xxx.xxx.xxx] or [ip6-address]

    What I need to do is remove the [ and ] so I and use the list generated to
    do ipf rules. Then later I need to add them when I have ip's rather than
    fully qualified domain names to send mail. I am able to do this in perl,
    but I really need to stay in in the shell. The output above is from an
    awk command.

    Could someone assist. It seems my sed is way to rusty.

    Thanks,

    --
    Boyd Gerber
    ZENEZ 1042 East Fort Union #135, Midvale Utah 84047

  2. Re: Sed adding and stripping [ and ]

    On Fri, May 02, 2008, Boyd Lynn Gerber wrote:
    >Hello,
    >
    >I am being really dumb today. I can get perl to do it but I really need
    >to get things working with sed. I have a script that is pasrsing input
    >and what I get is
    >
    >[xxx.xxx.xxx.xxx] or [ip6-address]
    >
    >What I need to do is remove the [ and ] so I and use the list generated to
    >do ipf rules. Then later I need to add them when I have ip's rather than
    >fully qualified domain names to send mail. I am able to do this in perl,
    >but I really need to stay in in the shell. The output above is from an
    >awk command.
    >
    >Could someone assist. It seems my sed is way to rusty.


    This should do it (I tried s/[\[\]]//g but that didn't work for me).

    sed -e 's/\[//g' -e 's/\]//g'

    Bill
    --
    INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC
    URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
    Voice: (206) 236-1676 Mercer Island, WA 98040-0820
    Fax: (206) 232-9186

    If you make yourselves sheep, the wolves will eat you -- Benjamin Franklin

  3. Re: Sed adding and stripping [ and ]

    On Fri, 2 May 2008, Bill Campbell wrote:
    > On Fri, May 02, 2008, Boyd Lynn Gerber wrote:
    > >I am being really dumb today. I can get perl to do it but I really need
    > >to get things working with sed. I have a script that is pasrsing input
    > >and what I get is
    > >
    > >[xxx.xxx.xxx.xxx] or [ip6-address]
    > >
    > >What I need to do is remove the [ and ] so I and use the list generated to
    > >do ipf rules. Then later I need to add them when I have ip's rather than
    > >fully qualified domain names to send mail. I am able to do this in perl,
    > >but I really need to stay in in the shell. The output above is from an
    > >awk command.
    > >
    > >Could someone assist. It seems my sed is way to rusty.

    >
    > This should do it (I tried s/[\[\]]//g but that didn't work for me).
    >
    > sed -e 's/\[//g' -e 's/\]//g'


    Thanks, that works for stripping.

    Thanks,

    --
    Boyd Gerber
    ZENEZ 1042 East Fort Union #135, Midvale Utah 84047

  4. Re: Sed adding and stripping [ and ]

    Boyd Lynn Gerber wrote (on Fri, May 02, 2008 at 06:06:44PM -0600):

    | Hello,
    |
    | I am being really dumb today. I can get perl to do it but I really need
    | to get things working with sed. I have a script that is pasrsing input
    | and what I get is
    |
    | [xxx.xxx.xxx.xxx] or [ip6-address]
    |
    | What I need to do is remove the [ and ] so I and use the list generated to
    | do ipf rules. Then later I need to add them when I have ip's rather than
    | fully qualified domain names to send mail. I am able to do this in perl,
    | but I really need to stay in in the shell. The output above is from an
    | awk command.

    Why not remove them in the AWK code before writing them out?

    | Could someone assist. It seems my sed is way to rusty.
    |
    | Thanks,
    |
    | --
    | Boyd Gerber
    | ZENEZ 1042 East Fort Union #135, Midvale Utah 84047

    Bob

    --
    Bob Stockler +-+ bob@trebor.iglou.com +-+ http://members.iglou.com/trebor

+ Reply to Thread