Code Snippets: Replace lines on multiple files

find . -type f -exec sed -i 's/$result2 = mysql_query($sql2, $link)/$result2 = $conn->query($sql2)/gI' {} \;

Find files in the current directory and search for a string similar to the one on the first / / block (in italics) and replace that with the string on the second / / block.

I recently used this to update the MySQL connection code on an old school project that I did. As I found out, the mysql_query (and other similar commands) have been deprecated already my the newer MySQLi commands.