Hi all.
Using PHP, how to find all the files in the whole system (I am using ubuntu) which contain string errorlog
.
I tried exec()
and grep
but it is taking just one occurrence. Thanks.
views:
53answers:
3well using php it would need a routine that walkes the whole system, for example recursivly, open each file with a certain ending and then walk this file and watch every line for the appereance of the sting and when finding the string just save it somewhere.
BTW PHP isnt't the best candidate for searching the whole system for an appearance of a certain string. If possible i'd rather take another language that is a bit faster on handling system near tasks.
Under windows i use notepad++ as a Tool to search a certain folder with all its subfolders for all occurences of a certain string.
Do you mean on the servers /*; or just a sub directory structure?
It does sound like you want to use shell out to find though.
http://www.athabascau.ca/html/depts/compserv/webunit/HOWTO/find.htm#EX03
(Searches pwd; i'd look into -maxdepth for performance reasons)
find . -exec grep "www.athabasca" '{}' \; -print