How to search and replace
charlescurley at charlescurley.com
Thu Feb 2 17:06:52 UTC 2006
On Thu, Feb 02, 2006 at 03:20:42PM +0000, Dan Track wrote:
> I thought I'd ask this here as you guys helped me setup mrtg :)
> I've got the following pattern in a text file in linux.
> Target[description1].18.104.22.168.5.3.:string at 10.11.8.10
> Directory[description1]: server1
> Target[description2].22.214.171.124.4.9.:string at 10.17.5.24
> Directory[description2]: server2
> What I would like to do is replace the ip of each with the following
> value of "Directory". So for example I would like
> Target[description1].126.96.36.199.5.3.:string at 10.11.8.10 to become
> Target[description1].188.8.131.52.5.3.:string at server1.example.com
> How can I accomplish this using either C,perl,sed or awk
If this is an ongoing issue, I'd check the documentation for the
originating program and see if there's an option to do reverse lookup
on the IP addresses.
Failing that, I'd a perl script to detect the IP addresses, do the
lookup, then substitute the domain name for the IP address.
Charles Curley /"\ ASCII Ribbon Campaign
Looking for fine software \ / Respect for open standards
and/or writing? X No HTML/RTF in email
http://www.charlescurley.com / \ No M$ Word docs in email
Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/users/attachments/20060202/7432866d/attachment-0002.bin
More information about the users