Click to See Complete Forum and Search --> : How to use GREP/FIND to search a string in all the subdirectories and files


sravan2000
11-07-2000, 08:10 PM
Hi

Could anyone know how to use the unix GREP/FIND to find a string in all the files and directories(including subdirectories and files)

there are some hardcoded IP's at the server level, so i need to find the string in all the files, starting from root.

any ideas ????

thanx in advance..


sravan

denevge
11-08-2000, 02:17 AM
use

find / -type f -exec grep -l "IP" {} \;

why ?

find / -type f -> find all files starting from /
find .... -exec -> for each item found, do the following command. Where you normally place the filename in you command, put {} .
grep -l "IP" something -> returns the filename if string "IP" is found in file something

Hope this helps
Gert

sravan2000
11-08-2000, 01:13 PM
Thanx!!! for your advice.... it helped me a lot.