User Tools

Site Tools


how_to_remove_script_from_all_pages

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

how_to_remove_script_from_all_pages [2009/06/04 11:09] (current)
k2patel created
Line 1: Line 1:
 +==== How to remove script from all pages ====
 +Xargs can be wack sometimes, you can use -exec in find to do the same thing as xargs:
  
 +find . -name '​*.php'​ -o -name '​*.htm*'​ -exec grep iframe {} \+ | cut -d ':'​ -f1
 +
 +<code bash | cleancode.sh>​
 +#this should be run in the root directory that needs to be cleaned
 +#!/bin/sh
 +
 +
 +TODAY=$(/​bin/​date +%m%d%y)
 +
 +
 +for i in $(find .  \( -name '​*.php'​ -o -name '​*.htm*'​ \) -exec grep -i '<​script>' ​ {} \+ | cut -d ':'​ -f1 ); do
 +  if [ -e $i ]; then
 +
 +    if [ -e $TODAY.backup.tar ]; then
 +      TFLAG="​rvf"​
 +    else
 +      TFLAG="​cvf"​
 +    fi
 +
 +     tar $TFLAG $TODAY.backup.tar $i
 +     perl -pi -e '​BEGIN{undef $/}' -e "​s/<​script>​function.*\/​script>//​g"​ "​$i"​
 +     echo Cleaned $i
 +  fi
 +done
 +
 +</​code>​
how_to_remove_script_from_all_pages.txt ยท Last modified: 2009/06/04 11:09 by k2patel