Bash Shell Scripting One Liners
Finding Code in PHP files
This will list all .php files that contain a certain string. Just replace {token} with whatever string you’re searching for. I use this when I have to automate figuring out which PHP files include other PHP files.
find ./ -name '*.php' | sed 's/^\(.*\)$/"\1"/g' | xargs grep -lF '{token}'
Handling file names with Spaces with find and xargs find can find files with spaces in their file names. This makes xargs go crazy unless you:
find ./ -type f -print0 | xargs -0 ...
The -print0 instructs find to end each search results with a NUL character. The -0 instructs xargs to use a NUL character as a separator. Neato
Example of how to find missing sequential files. I have a bunch of files named: 001.zip, 002.zip, 003.zip, etc. This helps me find if there are any missing files.
c=318; until [ $c -lt 1 ]; do a=`printf '%03d' $c`; \\
if [ ! -f "${a}.zip" ]; then echo "Missing ${a}.zip"; fi; let c-=1;

{ 1 comment… read it below or add one }
For searching inside files you can also try..
grep -Lr -include ‘*.php’ token
However, different versions of grep take different command line options.
If yours doesnt have a way to specify a filename filter
You can try..
find ./ -name ‘*.php’ -exec grep -L token {} \;
Rajesh Duggal