sed: remove from line X to line Y ??

From: Alan Murrell (swasak_at_hotmail.com)
Date: 06/08/03


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>



Relevant Pages

  • Re: Making a script into a service
    ... from just reviewing it. ... $1 is the word after the script command, ... Okay? ... See man bash for more info, or search for bash scripting guide. ...
    (comp.os.linux.misc)
  • Re: Help - a question on Unix/Linux script
    ... > This is a newbi question on Unix/Linux script. ... # With help from Advanced Bash Scripting Guide by Mendel Cooper v 2.1 ...
    (comp.unix.shell)
  • Re: A bash script
    ... > Chadley Wilson wrote: ... > Greetings I am about to start a script for installing a couple of updates ... Thank you Paul I do have the bash scripting guide ...
    (Fedora)
  • Re: WORD doc info into FMP?
    ... it appears that each line of the entry follows the format ... number of any given type of field (Location, script, sets etc.) you might ... into a separate record in a database, and a separate related "database 2" ... Ten Nights in a Barroom (New York State Archives) ...
    (comp.databases.filemaker)
  • RE: Need some MySQL query help...
    ... attempting to run the script: ... passed to the database. ... passwd entry to the current database entry. ...
    (perl.dbi.users)