Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to search & delete inclusively between two lines? Post 303042146 by chatguy on Monday 16th of December 2019 12:44:15 PM
Old 12-16-2019
How to search & delete inclusively between two lines?

Hi all, I was wondering if anyone would know how to search & delete inclusively between two lines, please:

Important:
  • There are multiple }; lines. I'm curious how to delete the correct one only.
  • Line numbers may vary each time this script is run.

For example, I'd like to delete only the entire entry called deletethisentry.com
Code:
zone "localhost" {
        type master;
        notify no;
        file "db.myzone";
};

zone "deletethisentry.com" {
        type master;
        notify no;
        file "db.myzone";
};

zone "keepthisentry.com" {
        type master;
        notify no;
        file "db.myzone";
};

Thanks so much!
CG


Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes them far easier to read and preserves multiple spaces for indenting or fixed-width data.

Last edited by rbatte1; 12-17-2019 at 06:55 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search 2 lines and delete above line

Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1: file1 word1... (4 Replies)
Discussion started by: shamushamu
4 Replies

2. Shell Programming and Scripting

Advanced Search & Delete Text File

I have a file in which email messages are stored in. Every email is separated by by a ^Z character (Control-Z). I need to extract all emails after the 65,00th one to another file and delete them from the original file. Any suggests on accomplishing this? (2 Replies)
Discussion started by: maxcell
2 Replies

3. Shell Programming and Scripting

search a word and delete consecutive lines below it

Hi all coders, I need a help to process some data. I have this file, 3 09/21/08 03:32:07 started undef mino Oracle nmx004.wwdc.numonyx.co m Message Text : The Oracle session with the PID 1103 has a CPU time consuming of 999.00... (3 Replies)
Discussion started by: vikas027
3 Replies

4. Shell Programming and Scripting

Delete new lines based on search criteria

Hi all! A bit of background: I am trying to create a script that formats SQL statements. I have gotten so far as to add new lines based on certain match criteria like commas, keywords etc. In the process, I end up adding newlines where I don't want. For example: substr(colName, 1, 10)... (3 Replies)
Discussion started by: jayarkay
3 Replies

5. Shell Programming and Scripting

awk search & delete located criteria

Guys, I manages to get awk to search and print the files that I want to delete. However I am stuck on the delete portion. Here is the command that I am using to fins these files. find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/' The output is perfect. The files look like so: ... (4 Replies)
Discussion started by: jaysunn
4 Replies

6. UNIX for Dummies Questions & Answers

How get only required lines & delete the rest of the lines in file

Hiiii I have a file which contains huge data as a.dat: PDE 1990 1 9 18 51 28.90 24.7500 95.2800 118.0 6.1 0.0 BURMA event name: 010990D time shift: 7.3000 half duration: 5.0000 latitude: 24.4200 longitude: 94.9500 depth: 129.6000 Mrr: ... (7 Replies)
Discussion started by: reva
7 Replies

7. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

8. Shell Programming and Scripting

search and delete the lines in a file

HI group members I am new in unix I want to search # symbol in a file. if found need to delete the entire row in the file. need to move the actual data(with out # symbol data) to another file. Thanks (2 Replies)
Discussion started by: pmreddy
2 Replies

9. Shell Programming and Scripting

sed search pattern and delete lines

Hello, i have a question. My problem is that i have a file like: TEST JOHN ADAM MICHAEL SEBASTIAN ANDY i want find for MICHAEL and want delete lines like this: TEST (4 Replies)
Discussion started by: eightball
4 Replies

10. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies
NSDC(8)                                                             NSDC 3.2.12                                                            NSDC(8)

NAME
nsdc - Name Server Daemon (NSD) control script. SYNOPSIS
nsdc [-c configfile] start | stop | reload | rebuild | restart | running | update | notify | patch DESCRIPTION
Nsdc is the shell script that used to control nsd(8) and zonec(8) from NSD distribution. Nsdc is also suitable to be linked into /etc/rc.d directory on BSD like systems for automatic startup of nsd(8) at boot time. At every invokation, nsdc will try to read the nsd.conf(5) configuration file. An example of such configuration file is distributed with the NSD package as nsd.conf.sample. The config file is checked for errors before it is used, see nsd-checkconf(8). Possible nsdc applications are: start Start nsd(8). stop Shut down nsd(8) by sending SIGTERM to it. reload Initiate nsd(8) name space database reload by sending SIGHUP. rebuild Rebuild the nsd(8) database by invoking zonec(8) with appropriate arguments. restart Restart nsd(8). This equals to nsdc stop && nsdc start. running Check whether nsd(8) is running. Returns error message and error code if it is not running, and no message and zero error code oth- erwise. update Updates all the slave zones which have allow-notify: from localhost (127.0.0.1 or ::1) allowed. If a TSIG key is specified for the allow-notify statement in the config file, it will be used to secure the notify. Note that NSD keeps track of zone timeouts automat- ically, this is only needed if you want to manually force updates by sending notify messages to the localhost. Another method you can use is to stop nsd, delete the xfrd.state file and then start nsd again. It will try to update all zones. This method does not require allow-notify: statements. notify Sends notify messages to all the slaves for all the zones that have the notify: keyword in the nsd.conf file. If a TSIG key is spec- ified for a notify statement, it will be used to secure the notification message to that slave server. patch Merge zone transfer changes back to zone files. It reads in the nsd database (nsd.db) and difffile (ixfr.db), and overwrites the zone text files if they have been updated. Running this regularly ensures that the difffile does not grow infinitely. If any zone text files have been changed (including those of the master zones), the nsd.db is rebuild and nsd is reloaded. OPTIONS
-c configfile Specify configfile to use instead of the default /etc/nsd3/nsd.conf. FILES
/etc/nsd3/nsd.conf Configuration file for nsd to change default pathnames and NSD flags. The zone names, pathnames to zone files and access control lists are also in nsd.conf(5). /var/lib/nsd3/nsd.db default NSD database /var/lib/nsd3/nsd.db.lock Lockfile for the NSD database access by operator tools. /var/lib/nsd3/ixfr.db Journal of zone transfers, the diff file containing the new zone contents transferred. /var/lib/nsd3/xfrd.state State for the zone transfer process of NSD. Contains timeouts for the zones and whether zones are expired. /var/run/nsd3/nsd.pid the process id of the name server. DIAGNOSTICS
Nsdc will return zero return code if operation was successful and an error message to standard output plus a non-zero return code other- wise. SEE ALSO
nsd(8), nsd.conf(5), nsd-checkconf(8), nsd-notify(8), nsd-patch(8), nsd-xfer(8), zonec(8) AUTHORS
NSD was written by NLnet Labs and RIPE NCC joint team. Please see CREDITS file in the distribution for further details. BUGS
Syntax checking of the config file is rudimentary and error messages may be wrong. If you do a nsdc patch, whilst a (long) zone transfer is busy, the zone transfer contents will be partially lost. After a reload, this will be detected and the zone transfer should be restarted. The reload that happens at the end of nsdc patch also frees up memory churn in NSD caused by zone transfers. NLnet Labs jul 19, 2012 NSDC(8)
All times are GMT -4. The time now is 05:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy