remove contents including the tag if pattern matches


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove contents including the tag if pattern matches
# 1  
Old 06-03-2011
remove contents including the tag if pattern matches

Hi all,

Can anyone help me on this. I have several WP sites that are affected by sql injections. But the contents are different as follows

western union india belgaum
western union india bolegaon
western union india barhaj
western union india budhana
western union india belda
western union india attayampatty (tn)
western union india biagdangdo
western union india avanashi


They are followed different url's. Is there any script that can be used to delete the contents in a tag including the tag if any of the pattern matches..

Suppose I am giving the pattern "india" in the script, the script have to delete the injected line with india including the tag from the database.

Can anyone help ?
# 2  
Old 06-03-2011
Please post some input sample and desired output .
# 3  
Old 06-03-2011
Here are another injected patterns


Code:
<a href=\"http://cialis-pharmacy-review.com\">Cialis</a>

<a href=\"http://cialis-pharmacy-review.com\">Cheap Cialis Super Active</a>

<a href=\"http://cialis-pharmacy-review.com\">Buy Cialis Super Active</a>

Database contents including the pattern

---------------------------------
Code:
<a title=\"Emotional Wealth Secret: Developing Emotional Awareness\" href=\"http://emotionalwealthacademy.com/ews-developing-emotional-awareness/\">Read and Download the Emotional Wealth Secret Fact Sheet: <a href=\"http://cialis-pharmacy-review.com\">Buy Cialis Super Active</a>

---------------------------------

My idea is creating a script and given the pattern "pharmacy" so that it will delete the line including the tags . From <a href=....................</a>
# 4  
Old 06-03-2011
Check if this works.

Code:
 
perl -lne 'print if !/pharmacy/' te

# 5  
Old 06-03-2011
What kind of database are you using? MySQL, Postgres, MSSQL, Oracle, ...?
# 6  
Old 06-03-2011
Mysql

---------- Post updated at 07:32 AM ---------- Previous update was at 07:32 AM ----------

Thank you getmmg. That did it

Thanks again....
# 7  
Old 06-03-2011
Smilie
Quote:
Originally Posted by sanjuabraham
Mysql

---------- Post updated at 07:32 AM ---------- Previous update was at 07:32 AM ----------

Thank you getmmg. That did it

Thanks again....

Pleasure Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete a pattern including any whitespace before it and after it

Hello. A_LIGNE="cnezJ,V ,FMZ fd,Mok CODKJ,F SOME_WORD fcnQ, VMQKV Q" A_PATTERN="SOME_WORD" sed 's/'$A_PATTERN'//g' <<< "$A_LINE"will remove 'SOME_WORD' and give : "cnezJ,V ,FMZ fd,Mok CODKJ,F fcnQ, VMQKV Q"A_PATTERN="SOME_WORD]" sed 's/'$A_PATTERN'//g' <<< "$A_LINE"will remove... (4 Replies)
Discussion started by: jcdole
4 Replies

2. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

3. Shell Programming and Scripting

Remove entire line from a file if 1st column matches a pattern

I have one requirement to delete all lines from a file if it matches below scenario. File contains three column. Employee Number, Employee Name and Employee ID Scenario is: delete all line if Employee Number (1st column) contains below 1. Non-numeric Employee Number 2. Employee Number that... (3 Replies)
Discussion started by: anshu ranjan
3 Replies

4. Shell Programming and Scripting

How to use ls with pattern and including path?

Hello to all, Maybe someone could help me, my question is: How can a filter the print of command ls for the files with names of the form "abc*.txt" including the path? I've done this: If I move with command cd to /My/Path/Is/This/ and send this command: ls -lst abc*.txt -i... (37 Replies)
Discussion started by: Ophiuchus
37 Replies

5. UNIX for Dummies Questions & Answers

If user input matches file contents

I was wondering how I can read values from a file and then proceed if those values match a user input. For example (a simple one), a user inputs their name, then we check if that name is in a file of usernames. If it is, it says proceed, if not, then it says you are not authorized. ... (5 Replies)
Discussion started by: DBnixUser
5 Replies

6. Shell Programming and Scripting

NAWK to remove lines that matches a specific pattern

Hi, I have requirement that I need to split my input file into two files based on a search pattern "abc" For eg. my input file has below content abc defgh zyx I need file 1 with abc and file2 with defgh zyx I can use grep command to acheive this. But with grep I need... (8 Replies)
Discussion started by: sbhuvana20
8 Replies

7. Shell Programming and Scripting

Search for Pattern and Print including Lines in between

Gurus, I have a big file that needs to be sorted out and I cant figure out what to do. The file name is as below: Name: xxxx yyyy nnnn Description: dfffgs sdgsgsf hsfhhs afgghhjdgj fjklllll gsfhfh Updated: jafgadsgg gsg Corrected: date today The file consists of line like these. ... (13 Replies)
Discussion started by: The One
13 Replies

8. Shell Programming and Scripting

Remove if the above line matches pattern

but keep if does not I have a file: --> my.out foo: bar foo: moo blarg i am on vacation foo: goose foo: lucy foo: moose foo: stucky groover@monkey.org foo: bozo grimace@gonzo.net dear sir - blargo blargo foo: goon foo: sloppy foo: saudi gimme gimme gimme (3 Replies)
Discussion started by: spacegoose
3 Replies

9. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

10. Shell Programming and Scripting

Extracting XML Tag Contents

Hi Jean I require your help in writing a shell script. Iam zero in Unix programming. I have a large file about 400 MB of data, which contains about 50000 XML messages seperated by a Tab, I think. I need to extract only 4 values from each XML message and write it onto a new file. Please help me... (2 Replies)
Discussion started by: pk_eee
2 Replies
Login or Register to Ask a Question