The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
shell script to edit file and delete entry tannu Shell Programming and Scripting 6 09-09-2008 03:04 PM
userpw.h AIX ( delete entry from the shadow password database ) nighter High Level Programming 4 07-15-2008 02:06 PM
delete dhcp.conf entry using sed tizatron Shell Programming and Scripting 2 11-26-2007 05:59 PM
HOSTS File cymerman UNIX for Dummies Questions & Answers 4 01-19-2007 12:26 PM
how to delete entry in file "wtmpx"(/var/adm/wtmpx) arm_naja UNIX for Advanced & Expert Users 4 03-08-2006 04:00 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 10-16-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
delete entry from /etc/hosts file ?

Hi there

I have a requirement where i have to globally remove a hosts file entry from all boxes e.g.

Code:
10.01.10.1           my_server1
normally for 'in-line' editing of files without passing it out to another fle and copying it back etc which is messy, Ive been using the fantastic "perl -pi -e" substitution command. However in this case I want to literally delete the line which im not sure that the perl command can do ?

But ....two things

I want to make sure i delete the line ONLY if both the ip AND the hostname are as defined (so that i know im deleting only this line)

and

the gap between the IP and hostname within the hosts file is variable with any potential number of spaces or tabs in between the two

Does anybody have an idea on how i can achieve this ?

Any help on this would be great
  #2 (permalink)  
Old 10-16-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
its ok, worked it out
Code:
perl -pi -e "s,^10.10.10.1.*my_server1\n$,," /etc/hosts
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 09:46 AM.


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