Tags

, , , , , ,

Search & replace a text from a file using perl is very easy.

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

Example :
perl -pi -w -e ‘s/<\/HEAD>/<?php include($_SERVER[DOCUMENT_ROOT].”\/includes\/tips_top.php”);?>\n<\/HEAD>/g;’ *.php

Reference : http://www.liamdelahunty.com/tips/linux_search_and_replace_multiple_files.php

Advertisements