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?


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.


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.

  • but I have strigs like usergetdate( or getdate( and I don't want those be replaced! – RYN 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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