I needed to replace domain name in MySQL DB dump which was 700MB, so i’ve googled a bit to find a command line expression. If you need to search/replace in files via command line, you can simply use following command (if perl is installed):

perl -pi -w -e 's/search/replace/g;' *.php
-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop

For example we can replace css link in all template files: