A few useful commands for the replacement of the mass

A few useful commands. Ex: rename html files to php, add tag translate, virtual, include, links html to php

Here are a few useful commands :


# renames html in php in the rep power. 
find-iname '*.html' | xargs -l | sed -e "s/\(.*\).html/mv \1.html \1.php /g" | bash 

# add the tag translate 
sed -i 's/>\([^<">]*\)</><!--?= t("\1")?-->/<\?php include($_SERVER["DOCUMENT_ROOT"]."blocks\/\1\.php")?>/g' *.php 
sed -i 's/<\!--#include virtual="\/common\/\(.*\).html" -->/<\?php include($_SERVER["DOCUMENT_ROOT"]."common\/\1\.php")?>/g' *.php 

# replace the href links to .html-to .php 
find-iname '*.php' | xargs egrep '\.html\"' | cut-d ":" -f2 | sed -e "s/^ *//g" | sed -e "s/.*href=\"\([^\"]*\).html\.*\".*/rpl -R '\1.html' '\1.php' *.php /" | bash