You have answered your own question - just use python with re, fileinput & possibly even os.walk:
- open source command line tool recursive search and replace in text
- supports PCRE like Python does. Yes exactly like python!
- Installable via RPM/DPKG Yes If you don't have it already
- Ubuntu 14.04 without adding an extra package repo. Yes
- support for interactive search+replace. A python script can prompt the user for missing fields.
- Scripting solutions using sed, awk, ... are no solutions in my eyes
A starting point:
for line in fileinput.input(inplace=1, backup='.bak'):
line = re.sub('foo','bar', line.rstrip())
this can even be done directly from the command line with:
python -c "import re, fileinput;for line in fileinput.input(inplace=1, backup='.bak'):; line = re.sub('foo','bar', line.rstrip()); print(line);" list_of_files
but you probably don't wish to type all of that every time. So something like:
wcreplace Find and replace wildcards on input files
wcreplace findwc replacewc file...
if len(sys.argv) < 4:
print("ERROR: Not enough parameters")
findwc = sys.argv
replacewc = sys.argv
for line in fileinput.input(sys.agv[3:], inplace=1, backup='.bak'):
line = re.sub(findwc, replacewc, line.rstrip())
Put in a file called
wcreplace, somewhere on the path like
/usr/bin and set to executable with
chmod 755 wcreplace should do the job.
Note: The above is untested! so test before use!