replace a complex string with null

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting replace a complex string with null
# 1  
Old 02-11-2008
replace a complex string with null


I need a script or one liner possible in perl or awk ( as sed shows error )

I want to replace

<?php echo file_get_contents("".$_SERVER['HTTP_HOST']);?>

with blank or null

1) in a file

2) in many directories recursively.

sed error is:

root@server [/home/xxxxxxx/public_html]# sed 's/error_reporting(0); echo file_get_contents(\"\\"\.$_SERVER['HTTP_HOST']);//g' ./framework/view/app/inc/header.php
sed: -e expression #1, char 57: Unknown option to `s'
root@server [/home/xxxxxx/public_html]#

please advise
# 2  
Old 02-11-2008
You need to escape those / characters in the http:// - sed thinks that's the end of the expression and is getting confused.
# 3  
Old 02-12-2008
No success still:

sed 's/error_reporting(0); echo file_get_contents("http:\/\/\".$_SERVER['HTTP_HOST']);//g' ./framework/view/app/inc/header.php
# 4  
Old 02-12-2008
I also see you've got some unescaped single quotes in there too, that'll break it. The brackets are likely to be interpreted as groupings instead of characters, so they won't get matched correctly.

Just work through the entire thing escaping any special characters.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace null values in csv with zero

Hi, i have another issue: i have three files: FILE 1 ServiceEventHandler, Processed,Percentage 5285337,100% FILE 2 Wallet, Processed,Percentage 5285337,100% (1 Reply)
Discussion started by: reignangel2003
1 Replies

2. Shell Programming and Scripting

Replace pipe delimited column string to null

Hi All, I have a large dat file where each lines are pipe delimited values. I need to parse the file depending on the request. For example: sometimes I have told to remove all the values in the 7th column (this case remove values '3333' only from the first line and '3543' from the second line)... (4 Replies)
Discussion started by: express14
4 Replies

3. Shell Programming and Scripting

Replace 0's with NULL

Hi all, Need a small help I am in lookout for a command that changes 0's to NULL in my file, The content will look like 1139,223108,R,2009,0,854,854,854,732,854,854,854,854,854 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... (3 Replies)
Discussion started by: Sri3001
3 Replies

4. Shell Programming and Scripting

Complex find and replace only 1st instance string with dynamic combination

test.txt is the dynamic file but some of combination are fix like below are the lines ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off = disabled the test.txt can content them in any order #cat test.xt ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off =... (5 Replies)
Discussion started by: SilvesterJ
5 Replies

5. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

6. Shell Programming and Scripting

replace some string by null??

I have a string like In this string I want to delete both "." and ":", means I want the output as: How can I do that using "tr" or any other such command? (6 Replies)
Discussion started by: ash.g
6 Replies

7. Shell Programming and Scripting

Replace 4th field if null

Hi .. Can some one please suggest me how to replace 4th field(column) of a .csv file with "NA" if it is null. Input file data: |A|21|B1||1.1| |A|21|C|RAGH|1.1| |A|21|D1||1.1| |A|21|C|YES|1.1 Expected Output |A|21|B1|NA|1.1| |A|22|C|RAGH|1.1| |B|23|D1|NA|1.1| |A|24|C|YES|1.1| Thank... (4 Replies)
Discussion started by: pasupuleti81
4 Replies

8. Shell Programming and Scripting

pls help! complex find and replace

help pls... i would like to change this CURVE2 565489 789458 1258649 random data here... CURVE2 565489 568795 6548921 random data here... CURVE2 565489 123598 6446259 random data here... CURVE2 565489 672956 2489657 into this CURVE2 565489 586423 1258649 random data here...... (2 Replies)
Discussion started by: lakanino
2 Replies

9. Shell Programming and Scripting

Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same. I tried this: tr "\000" "\040" < mainfile > newfile Does not work. I tested that it works the other way round: $ echo "hello" |tr... (1 Reply)
Discussion started by: rikxik
1 Replies

10. Shell Programming and Scripting

Replace 3 fields with null in the file

Hi, I have a file with 104 columns delimited by comma. I have to replace fields 4,5 and 19 with null values and after replacing the columns in the file , the file should be still comma delimited. I am new to shell scripting, Experts please help me out. Thank you (1 Reply)
Discussion started by: vukkusila
1 Replies
Login or Register to Ask a Question