I need to replace text in lots of files. I'm using rpl for this purpose, but I can't find any way to make it use regular expressions. Can rpl use "regex"? how?

I'm using rpl 1.5.2 from Ubuntu 13.04 repositories.

  • 2
    Some of the approaches explained here might work for you. – terdon Feb 18 '14 at 13:35

Looking at the reference page for the original rpl it would seem to be able to support regex just fine.


See the following for examples of replacing character strings.

Note: If you are using a locale other than En_US, the following examples may not include all alphabetic characters.

  1. To replace a legal FORTRAN identifier (an alphabetic character followed by as many as five alphanumeric characters) with xxx, enter:

    $ rpl '[A-Za-z][A-Za-z0-9]{0,5}' xxx
  2. To replace all occurrences of the character string sky with blue sky in the skyfile file and put the result in the bluefile file, enter:

    $ rpl sky "blue sky" <skyfile >bluefile

However in testing the Linux version of rpl it doesn't appear that regex was implemented in this version. None of my testing was able to make use of any regex features.

  • Unfortunatly that doesn't work! I tried rpl '[A-Za-z]' 'T' test.txt and it found nothing while using rpl 'A' 'T' test.txt works! – RYN Feb 18 '14 at 8:50
  • 1
    @4r1y4n - that's what my testing is showing too. The original version from AIX did support this, but the linux ver. doesn't. As an alternative you could use sed or awk. – slm Feb 18 '14 at 8:58

The 1.5.5 version on Linux does not support replacing regular expressions.

An alternative using SED is explained in https://stackoverflow.com/a/1583282

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.