Posted By

zlincoln on 09/27/12


Tagged

Bash unix perl


Versions (?)

Batch file content replace from template.php


 / Published in: Bash
 

Find and replace contents of files ending in .php with nothing. then append contents of template.php to all files in directory

  1. // find and replace all characters with nothing in files ending in .php
  2. perl -pi -w -e 's/.//g;' *.php
  3.  
  4. // find and replace all line breaks with nothing in files ending in .php
  5. perl -pi -w -e 's/\n//g;' *.php
  6.  
  7. // append contents of template.php to every file in directory
  8. for f in *; do cat ../template.php >> "$f"; done

Report this snippet  

You need to login to post a comment.