-   Linux - Newbie (
-   -   Need help with finding pattern in files (

DeeH 10-18-2007 02:53 PM

Need help with finding pattern in files
I am a very new Linux user and I need some assistance with finding something in the file system. My predessor left me instructions which were lost when our office was rearranged.
Basically I want to find all files in my system that contain the string '172.' I know this may be fairly large, so I would like to write the results to a text file.

I've tried

find / -type f -exec grep -lins "172." > dar172.txt {} \;

but it seems to go away and never comeback and of course I can't find dar172.txt anywhere on the system.

Thanks so much for any assistance


Dinithion 10-18-2007 03:40 PM

I can't really see the point in exec the grep command, perhaps I have missed a point here. This would work:

find / -type f -name '*172.*' > dar172.txt

Ah, If you want linenumbers, then this will do the trick:
find / -type f -name '*172.*' | grep -n "" > dar172.txt

Tinkster 10-18-2007 07:00 PM

No need to "find", really ...

grep -rnI 172 /etc/* /var/* /usr/local/* > dar172.txt

The reason that "find never comes back" may well be due to the
fact that you're going over /dev and/or /proc .... hence the
list of "sensible places" to look in.


All times are GMT -5. The time now is 01:53 PM.