Monday, June 25, 2012

One-Liner to Find All SQL in a Code Base


Ever been tracking down problems with SQL in some code you inherited, and wished you had an easy way to track down all the SQL in the code base? Here's a quick one-liner to do just that.

This example will find the most common SQL commands in a PHP code base:


find . -type f -iname "*php" -exec egrep -Hin "select.*from|insert into|delete from|update.*set" {} \; | less


Translation: Starting in the present working directory, recursively and case-insensitively find all files whose names end in php. For every matching file found, search the file for strings that denote SQL SELECT, INSERT, DELETE, or UPDATE syntax, matching case-insensitively, and for every matching line, print the name of the file in which it was found, and the line number that matched. Pipe the output to less so that you can go back and forth in the list.


A powerful tool that can be tweaked to match all kinds of situations.

Source from :James Parks, RHCE GROUP

rsync with delete option and different ssh port

How to rsync e.g PIPELINE dir from Source to Destination? #rsync -avzr   --delete-before  -e "ssh -p $portNumber"  /local...