The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed remove everything up to the pattern katrvu Shell Programming and Scripting 4 04-08-2008 10:35 PM
grep required pattern and next 2 or 3 lines cvvsnm UNIX for Dummies Questions & Answers 3 02-01-2008 05:20 AM
grep to show lines only after pattern wannalearn Shell Programming and Scripting 5 10-09-2007 03:44 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM
grep - to exclude lines beginning with pattern frustrated1 Shell Programming and Scripting 2 08-29-2005 08:18 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-29-2008
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
grep for particular pattern and remove few lines above top and bottom of the pattern

grep for a particular pattern and remove 5 lines above the pattern and 6 lines below the pattern




root@server1 [~]# cat filename

Shell Programming and Scripting test1
Shell Programminsada asda
dasd asd Shell Programming and Scripting Post New Thread
Shell Programming and S sadsa sadcripting Post New Thread
Shell Progsdaas dsadsaramming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
pattern_to_remove
Shell Programming and Scripting Post New Thread
Shell Programming awetrtg teyy teyer nd Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and rewrwt r t Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programmingsadas ade and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programming and Scripting Post New Thread
Shell Programminsadsa asdad`g and Scripting Post New Thread





Prefix each line of output with the line number within its input file.
#######################################################################################

root@server1 [~]# grep -n "pattern_" 12345
12attern_to_remove
root@server1 [~]#




Now I want that 5 lines before line number 12 and 6 lines after line number 12 be replaced with null or removed(deleted) with a script


Please advise

Last edited by fed.linuxgossip; 02-29-2008 at 12:46 PM.. Reason: spell
 

Bookmarks

Tags
linux, linux commands, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0