Re: Another sed problem...
From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 11/20/03
- Next message: Kevin Rodgers: "Re: Setting up Rsh"
- Previous message: Kevin Rodgers: "Re: Problem with read"
- In reply to: greyfell_at_zerobyte.org: "Another sed problem..."
- Next in thread: Kenan Kalajdzic: "Re: Another sed problem..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Nov 2003 11:11:07 -0800
greyfell@zerobyte.org wrote in message news:<b0oprvk2nk1cu8shg2ngfis9ic7uuhq5g4@4ax.com>...
> I'm trying to do a find and replace in sed. I'm pretty sure my problem
> is that some of the characters I'm replacing with are reserved
> characters for sed. I've tried both of these incarnations...
>
> sed -e "s/webserv .*\$/webserv !(dst host web1) or port ftp or port
> ftp-data or port 80 or port 433/g" </etc/pf.d/IP/net0
> >/etc/pf.d/IP/net0.mod
>
> sed -e 's/webserv .*$/webserv !(dst host web1) or port ftp or port
> ftp-data or port 80 or port 433/g' </etc/pf.d/IP/net0
> >/etc/pf.d/IP/net0.mod
>
> No luck with either. I just want to repace any line beginning with
> webserv (even if it is the first line), and replace it with...
>
> webserv !(dst host web1) or port ftp or port ftp-data or port 80 or
> port 433/g' </etc/pf.d/IP/net0
>
> Any help greatly appreciated. Thanks in advance.
If your shell is c-shell or it's derivative then we need to escape
the ! from the shell or use the 'sed -f' option. the -f option is
useful when u don't want the shell to cast any evil glances on your
sed commands lines.
sed -e '
/webserv/s/.*/webserv \!(dst host web1) or port ftp or port ftp-data
or port 80 or port 433/
' /etc/pf.d/IP/net0
## note: no need of the '/g' option as you are replacing the whole
line in one fell swoop.
or, put the following line in a file(say 'cmdfile') and
have sed use that for it's commands:
/webserv/s/.*/webserv !(dst host web1) or port ftp or port ftp-data or
port 80 or port 433/
then invoke sed as:
sed -f cmdfile /etc/pf.d/IP/net0
- Next message: Kevin Rodgers: "Re: Setting up Rsh"
- Previous message: Kevin Rodgers: "Re: Problem with read"
- In reply to: greyfell_at_zerobyte.org: "Another sed problem..."
- Next in thread: Kenan Kalajdzic: "Re: Another sed problem..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|