Personal tools
You are here: Home Docs Help! Reference Manuals Debian Reference Debian tips Nifty little commands to remember Regular-expression substitution

8.6.13. Regular-expression substitution

Up one level

-

Replace all instances of FROM_REGEX with TO_TEXT in all of the files FILES ...:

     $ perl -i -p -e 's/FROM_REGEX/TO_TEXT/g;' FILES ...

-i is for "in-place editing", -p is for "implicit loop over FILES ...". If the substitution is complex, you can make recovery from errors easier by using the parameter -i.bak instead of -i; this will keep each original file, adding .bak as a file extension.

(no ads!)