sed: remove from line X to line Y ??
From: Alan Murrell (swasak_at_hotmail.com)
Date: 06/08/03
- Next message: John L: "Re: remove from line X to line Y ??"
- Previous message: Stephane CHAZELAS: "Re: Using awk or cut to print every field after the 11th field"
- Next in thread: John L: "Re: remove from line X to line Y ??"
- Reply: John L: "Re: remove from line X to line Y ??"
- Reply: Alan Murrell: "Re: sed: remove from line X to line Y ??"
- Reply: Ian Gil: "Re: sed: remove from line X to line Y ??"
- Reply: Daniele Di Mattia: "Re: sed: remove from line X to line Y ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sun, 08 Jun 2003 19:39:12 GMT
Hello,
I am attempting to write a script that will allow me to remove the entry
from a '/etc/named.conf' file by supplying only the domain name. The
record in '/etc/named.conf' looks like this:
zone "domain.com" {
type master;
file "domain.com";
};
I would like to do something like 'grep "domain.com" /etc/named.conf', and
establish that as "line 1', then run sed to remove from "line 1" to "line
4". However, my efforts have been less than successful.
I referred to the "Advanced Bash Scripting Guide" at the Linux Documentation
Project", and I am able to remove specific line numbers by using 'sed -e Xd
/etc/named.conf' (where X is the line number). This counts line numbers
from the top of the file.
I also saw the following reference in the Guide:
1,/^$/d
which is supposed to "Delete from beginning of input up to, and including
first blank line." But when I run:
sed -e l,/^$/d /etc/named.conf
This results in the following error:
sed: -e expression #1, char 2: Extra characters after command
And of course, I did not see a way to input the expression I was looking for
(i.e., 'domain.com')
I would appreciate any pointewrs or advise that you would be able to give me
regarding this.
TIA,
Alan Murrell <swasak@hotmail.com>
- Next message: John L: "Re: remove from line X to line Y ??"
- Previous message: Stephane CHAZELAS: "Re: Using awk or cut to print every field after the 11th field"
- Next in thread: John L: "Re: remove from line X to line Y ??"
- Reply: John L: "Re: remove from line X to line Y ??"
- Reply: Alan Murrell: "Re: sed: remove from line X to line Y ??"
- Reply: Ian Gil: "Re: sed: remove from line X to line Y ??"
- Reply: Daniele Di Mattia: "Re: sed: remove from line X to line Y ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|