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!

Find hostname and IP inside files

Status
Not open for further replies.

Rasslor

Technical User
Dec 13, 2000
52
0
0
US
Hi,

Quick question about how can I search across my machine where refrences to my old IP and hostname are? I would basicly make a search that would go through every file on the system and let me know if my old server name is in any of them.

Thank you in advance for you help.
 
You could try something like:

for file in `find / -type f -print`
do
grep -l "<old-hostname>" $file
done

(NB: that is 'minus el')

I am sure I posted something similar within the last month or so. Did you try the 'search' facility?

Anyway, I hope that helps.

Mike
 
Hi there,

my favourite script for such reasons is the following:

find / -type f -exec grep -l 'searchterm' {} \;

(where of course 'searchterm' has to be replaced with the IP or hostname you are looking for. e.g. '172.19.2.4' ;-) )

But since this has been written for an AIX machine I'm not 100% sure whether this will work under Solaris or not ... Basically it should.

Regards
Thomas
 
Thank you guys for your quick response. I did try to search inside the forums for that info, but I guess my search terms didn't match the real answers!

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top