How to search entire filesystem for any file(s) containing specific ip address?

I've tried:
find / "ip.address.here"
...but this returns no hits and I know the IP address I'm searching for is contained within at least one file, but I've no idea where or what the file is?

Is there another way to search all files on a freebsd system for a specific IP address?
Thanks in advance.
 
If you are looking *inside* the files, then use grep -FIr ipaddr /, if you are looking for a filename, use find / -name \*ipaddr\*.
 
I've tried:
find / "ip.address.here"
find(1) looks for file or directory names, not their contents.

but this returns no hits and I know the IP address I'm searching for is contained within at least one file
So, it's likely a file within /etc/ or /usr/local/etc/, it's rather pointless looking for it in binaries.

grep -r "1\.2\.3\.4" /etc/* will grep(1) through each file within /etc/ looking for the IP address. Note that you need to escape the . because it's a re_format(7) and you want to check for a literal .
 
find(1) looks for file or directory names, not their contents.


So, it's likely a file within /etc/ or /usr/local/etc/, it's rather pointless looking for it in binaries.

grep -r "1\.2\.3\.4" /etc/* will grep(1) through each file within /etc/ looking for the IP address. Note that you need to escape the . because it's a re_format(7) and you want to check for a literal .
Thank you for the quick reply!
One of the IPs I'm searching for is: 92.118.39.237

So the command I should use is:
grep -r "92\.118\.39\.237" /etc/*
 
Or use -F which makes the pattern literal, should also be faster as it skips the regcomp()/regexec() altogether (IIRC).
So:
grep -FIr 92.118.39.237 /etc/*

rather than:
grep -r "92\.118\.39\.237" /etc/*
 
Code:
% grep -rsw  92.118.39.237  /etc
will do.

Code:
-r, --recursive

Non-root user:
-s, --no-messages
             Silent mode.  Nonexistent and unreadable files are ignored (i.e.,
             their error messages are suppressed).

-w, --word-regexp

-w for exact pattern, to exclude, for example, other than 192.168.39.1 (192.168.39.11, 12,101, etc).
 
To All:
I have to say that I haven't seen such quick, brilliant minds since doctors made house-calls.
I can't thank you all enough. Have a great weekend, guys!
 
Back
Top