LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices

Any code I post here should be considered experimental and unfinished. Don't use it in a production environment. It is your own responsibility to evaluate the code's fitness for any purpose. Programming isn't done in a vacuum, so be prepared to do your own research and teach yourself to do better.

Most importantly, all your polite critiques, elaborations, and corrections are heartily welcomed.
Old

How to kill lines before and after a pattern

Posted 12-21-2011 at 05:45 PM by Telengard (Here are some things which I hope will be helpful.)
Updated 12-21-2011 at 06:27 PM by Telengard
Tags awk

PHP Code:
#! /usr/bin/awk -f

# Deletes n lines before pattern and m lines after.
# Intended to be portable.
# It is your own responsibility to evaluate the fitness of this program.

BEGIN {
    
# set the following initializers as you please
    # FS=" "
    # OFS=" "
    
n=5
    m
=3
}

/
line 11/ { # insert your desired regex "pattern" between the slashes
    
pattern_line=FNR 
...
Member
Posted in programming
Views 814 Comments 0 Telengard is offline

  



All times are GMT -5. The time now is 04:50 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration