Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file manipulation 1

Status
Not open for further replies.

metro256

Technical User
Jan 28, 2002
9
0
0
US
Any recommendations for the following scenario?

I need a script that converts a single IP address to a hostname. This IP address is located in several different files in different directories.

Any help would be appreciated.

Thanks
 
as you say "several" files, it's probably easier to run the same script over each file, rather than write something that searches for the IP address in lots of places and does complicated things.

Create a script, called ip_fix.pl, like this:

while(<>){
s/123\.123\.123\.123/my.host.somewhere.com/g;
print;
}

Call the script like this.

ip_fix.pl < old_file.txt > new_file.txt

check the new file and then rename it so that it overwrites the old file. Mike
________________________________________________________________________________

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
thanks Mike, you get my vote for 'tipmaster' of the week (haha)
 
well thank you :)

I'm not really up there with the tmotw gods though <smile>

Glad you're sorted. Mike
________________________________________________________________________________

&quot;Experience is the comb that Nature gives us, after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top