I'm using rpl program in linux to replace date( with pdate( in some files.
But it says A Total of 0 matches replaced in 1 file searched.
while grep output for date( is:

ariyan@ariyan-laptop:/var/www/moodle21$ grep -wR 'date(' admin/uploaduser.php
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);

I'm using rpl as this:

rpl -wR 'date(' 'pdate(' admin/uploaduser.php

What is the problem?

link|improve this question

80% accept rate
does it bork on all files in that directory or just that one? permissions maybe? – aking1012 Oct 28 '11 at 19:23
@aking1012: All files. All Permissions are 777 ! – Snigger Oct 28 '11 at 19:28
1  
This question has been cross-posted to at least 3 SE sites: superuser.com/questions/351663/… askubuntu.com/questions/73322/… unix.stackexchange.com/questions/23512/… – Keith Thompson Oct 28 '11 at 20:39
feedback

1 Answer

up vote 3 down vote accepted

I've never used this tool before, but looking at the description of what "-w" I am guessing that it is handling word boundaries slightly different than expected. If you take the "-w" off, it should work. Additionally, in the example you've given it a single file to match against, so the -R isn't going to come into play either.

Try:

rpl 'date(' 'pdate(' admin/uploaduser.php

EDIT: After a bit of researching, I found that there is a bug reported for rpl not handling punctuation as word boundaries, which is why this isn't working. So the only option is to use another tool. Sed comes to mind for this task, so you can accomplish it with the following:

sed -i 's/\bdate(/pdate(/g' admin/uploaduser.php

That will do an inline replace (-i) the same way rpl would have done it and is matching for things that start date and replacing them with pdate.

link|improve this answer
but I have strigs like usergetdate( or getdate( and I don't want those be replaced! – Snigger Oct 28 '11 at 20:14
It looks like there is a bug with rpl that it doesn't handle punctuation as word boundaries. I was able to get it to work with the following sed statement though sed -i 's/\bdate/pdate/g' – Alex Oct 28 '11 at 20:25
Thank you very much – Snigger Oct 28 '11 at 20:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.