Friday, June 26, 2009

Read-optimize your source code

A good article about writing well-written code that will make it easy for other developers to quickly understand your code.

http://www.brendel.com/consulting/blog/2009/06/read-optimized-source-code.html

Another useful unix command to find text in many files

find . -type f -exec grep -il "text to find" {} \;

Will give you a list of all the files that contain "text to find", starting with your current directory and searching all sub-directories.

Tuesday, June 9, 2009

Useful unix command to find and replace text in many files

Here is a useful unix command I used today to find and replace text across multiple files and multiple directories.

find . -type f -exec sed -i "s/string1/string2/g" {} \;

This will replace all instances of string1 with string2.

Credit to Google and http://www.sb.fsu.edu/~soma/Proj/How-to/Search+Replace.pdf for helping me figure this out.