rpl - A Find & Replace Terminal Tool
Tonight I have mainly been working on Whird. I have been rewriting large chunks of code in an effort to optimise a bunch of functions. As a result of this, I had to change a series of strings in a number of files. As per normal when it comes to fiddly grep, sed and awk commands, I fired up Google and searched for some pointers. Whilst refreshing my memory, I came across a comment by an anonymous reader who suggested using the rpl command.
I had not previously come across rpl before, so I investigated. Turns out that rpl is a really handy text replacement tool — it makes recursive text replacement commands really simple; as simple as:
rpl [options] old_string new_string target_file(s)
Available options are:
--version show program's version number and exit
-h, --help show this help message and exit
-L, --license show the software license
-x SUFFIX specify file suffix to match
-i, --ignore-case do a case insensitive match
-w, --whole-words whole words (old_string matches on word boundaries only)
-b, --backup make a backup before overwriting files
-q, --quiet quiet mode
-v, --verbose verbose mode
-s, --dry-run simulation mode
-R, --recursive recurse into subdirectories
-e, --escape expand escapes in old_string and new_string
-p, --prompt prompt before modifying each file
-f, --force ignore errors when trying to preserve permissions
-d, --keep-times keep the modification times on modified files
-t, --use-tmpdir use $TMPDIR for storing temporary files
-a, --all do not ignore files and directories starting with .
rpl is available to install from the Ubuntu repositories, install with the following command:
sudo apt-get install rpl
For more information about rpl, see: http://www.laffeycomputer.com/rpl.html

Add Your Comment
Use the form below to add your comment. Markdown syntax is available. Note, comments are moderated by me for spam filtering. Alternatively, feel free to contact me privately.