User Tools

Site Tools


how_to_remove_script_from_all_pages

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

| 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
how_to_remove_script_from_all_pages.txt · Last modified: 2020/08/10 02:35 (external edit)