The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
delete entry from /etc/hosts file ?
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
delete entry from /etc/hosts file ?
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
1
(
permalink
)
10-16-2008
hcclnoodles
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
hcclnoodles
View Public Profile
Find all posts by hcclnoodles
Find hcclnoodles's past nominations received
Find hcclnoodles's present nominations given