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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
dynamic editing using shell script habzone2007 Shell Programming and Scripting 1 05-14-2008 07:55 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 01:25 AM
Editing files in shell programing nir_s Shell Programming and Scripting 0 07-13-2005 01:53 AM
Editing a file in a shell script jowpup UNIX for Dummies Questions & Answers 3 02-08-2005 12:45 AM
Editing a file using a script Ypnos Shell Programming and Scripting 45 07-02-2003 06:39 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2008
Registered User
 

Join Date: Dec 2006
Location: dallas tx
Posts: 43
Stumble this Post!
editing a file via a shell script ??

Morning All: I know this might be easy but since I don't do this very often I get stumped real quick... Sun box Solaris 8 ksh...

I need to edit a file via a shell script. In this file I need to locate one specific line and then remove that line plus the next 20 line below that....
Any suggestions on where to start?? I could use sed to search for the first line in question.. but not sure what to do after that.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-28-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,614
Stumble this Post!
Code:
sed '/matching line/{;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;d;}'
Sorry for posting my first answer before testing it. Actually I misread the question at first.

Last edited by era; 03-28-2008 at 04:46 AM. Reason: Too quick to post, duh
Reply With Quote
  #3 (permalink)  
Old 03-28-2008
Registered User
 

Join Date: Dec 2006
Location: dallas tx
Posts: 43
Stumble this Post!
Sweet.... Works like a champ !!
This was done from inside a script to I had to replace the ' with a "

sed "/$delnode/{;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;d;}" myfile

Last edited by jimmyc; 03-28-2008 at 09:07 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0