Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
does it bork on all files in that directory or just that one? permissions maybe? – RobotHumans Oct 28 '11 at 19:23
@aking1012: All files. All Permissions are 777 ! – RYN Oct 28 '11 at 19:28
This question has been cross-posted to at least 3 SE sites:……… – Keith Thompson Oct 28 '11 at 20:39
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.


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.

share|improve this answer
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
Thank you very much – RYN Oct 28 '11 at 20:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .