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

Closed Thread
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
  #1 (permalink)  
Old 04-29-2008
catgovind catgovind is offline
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
  #2 (permalink)  
Old 04-29-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,342
With awk you can do something like:


Code:
awk '/^<Location \/main>/{f=1;next}
f && /^<Location /{f=0}
!f' file

Regards
  #3 (permalink)  
Old 04-30-2008
catgovind catgovind is offline
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-30-2008 at 03:10 AM..
  #4 (permalink)  
Old 04-30-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

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

Regards
Closed Thread

Bookmarks

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 12:24 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