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
Removing the first and last lines in a file naveendronavall Shell Programming and Scripting 2 12-29-2007 10:22 PM
Removing a specific word from a created list erest8 UNIX for Dummies Questions & Answers 5 10-14-2007 02:11 AM
Removing parts of a specific field kieranh Shell Programming and Scripting 9 09-28-2007 09:52 AM
Removing lines from a file computersaysno UNIX for Dummies Questions & Answers 6 11-14-2006 03:50 PM
Removing lines from a file PradeepRed Shell Programming and Scripting 4 12-17-2005 03:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
Removing specific lines

Hi
I have a .conf file having many location tags like

<Location /main>
AuthName main
AuthUserFile /ppt/gaea/passwd_main
Require user admin
</Location>
......
...
<Location /wonder>
AuthName gaea
AuthUserFile /ppt/gaea/passwd_gaea
Require user admin
</Location>
.

now I want to remove a tag having attribute "main" through shell script .Please help me how do i remove this

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 04-29-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
With awk you can do something like:

Code:
awk '/^<Location \/main>/{f=1;next}
f && /^<Location /{f=0}
!f' file
Regards
Reply With Quote
  #3  
Old 04-29-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
Thank u franklin .its working . But it will print on the console .what i need is directly changed on the file

Last edited by catgovind; 04-29-2008 at 11:10 PM.
Reply With Quote
  #4  
Old 04-30-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,314
Redirect the output to a temporary file and replace the original file with it.

Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:11 PM.


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

Content Relevant URLs by vBSEO 3.2.0