Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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? –  hbdgaf Oct 28 '11 at 19:23
    
@aking1012: All files. All Permissions are 777 ! –  4r1y4n 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

1 Answer 1

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.

share|improve this answer
    
but I have strigs like usergetdate( or getdate( and I don't want those be replaced! –  4r1y4n 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 –  4r1y4n Oct 28 '11 at 20:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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