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?
Edit:
I'm using rpl 1.5.2
from Ubuntu 13.04
repositories.
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?
Edit:
I'm using rpl 1.5.2
from Ubuntu 13.04
repositories.
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.
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
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.
rpl '[A-Za-z]' 'T' test.txt
and it found nothing while using rpl 'A' 'T' test.txt
works!
– Ariyan
Feb 18 '14 at 08:50
sed
or awk
.
– slm
Feb 18 '14 at 08: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