Quote:
Originally Posted by Nejc
It seems Im getting somethig wrong here, since I am not very keen with Shell scripting. Here is the code which I put togheter with this forum topic:
Code:
find . -type f | while read i
do
sed "s:<?php echo '<script language='JavaScript'>function e590206b977().*<\\\/script>'; ?>::" file > temp
if cmp temp "$y" >/dev/null
then
rm temp
else
mv temp "$y"
fi
done
Am I doing something wrong here? ...
|
There are a few things that I'd change, first the variables ( highlighted ), you're using
i, y, file which (I guess) you're trying to represent the same thing - the file names.
I changed them below:
Code:
find . -type f | while read file
do
sed "s:<?php echo '<script language='JavaScript'>function e590206b977().*<\\\/script>'; ?>::" "$file" > "$file".temp
# check cmp's -s flag
if cmp -s "$file".temp "$file"
then
rm "$file".temp
else
# proceed with care here !!
mv "$file".temp "$file"
fi
done
Quote:
|
I added the "function string" above, since its a Joomla site, and it might already include such a string.
|
That's not an issue as long as the new string is a
continuos part of the initial one, but add cautiously, especially when you hit special characters. BTW the new string (
function e5... ) is not a problem.
Proceed with care when you rename the files, test first from the command line with a few files using only the
sed code, to be sure you're getting the right changes.