Using Unix Find to Locate WordPress Functions
I am a unix / linux web developer primarily and use some windows / mac editors for ease of use.
When it comes to locating code snippets within wordpress or other cms’ I find it easiest to do this within the linux shell using the find command with a little help from egrep.
generally speaking I can find what I am looking for quite easily using the often forgotten find command.
$ find ./ -type f -exec egrep 'what ever i am looking for' {} ;
This breaks down like this.
find -> the command you are running
./ -> the directory you are searching ( the slash makes it recursive from the starting dir )
-type f -> you only want files that are of type file, not directory or special, etc.
-exec -> tell find that you want to run another command on all the files found of type f
egrep ‘what ever i am looking’ {} -> run egrep on the current file found {} <- is the file
; -> just tell the find command you are done with options and attributes.
Egrep is very powerful when used in combination with the find command. It can be literal strings or regular expressions. man egrep or man grep to find out how to really unleash it raw power.
So remember when you are sifting through wordpress installs to find where functions or attributes or anything else for that matter to use find. You can also use this find / egrep combination on log files too.
You can man find to really get all the powerful feature to this command, and if you are good with linux shell commands you can do some really neat things with find and other commands all piped together. The possibilities are endless.