REPLACE, a script to replace text in files


What replace is good for

Ever wanted to make some nontrivial changes in a bunch of files ? E.g. replace all 'func_name_WHATEVER' by 'WHATEVER_newname':
replace '\bfunc_name_([a-zA-Z0-9]+)\b' '$1_newname' *.cc
does it. It will ask for each file if you want to accept the changes. If at some point you are sure that the changes for all coming files are correct, you answer 'PROCEED' and replace will go into non-interactive mode. If you want a diff of the changes made, use the -d option. The -D option suppresses all changes, only a diff file will be created that reflects all changes that would have been applied.

As you see replace can save a lot of work. See the verbatim help text for more options and usage examples.

Download replace and your life will be happier.


lastmod (uses replace)

lastmod is a shell script to insert the date of last modification into a file. It does not change the modification date of the file. It looks for a pattern like
# version:
and appends the date there, e.g.:
# version: 2001-April-07 (14:28)
The pattern can be supplied in an environment variable. This script is used to automatically set the date of last modification of my web pages and shell scripts.


Your feedback is appreciated.
jj (Jörg Arndt)

Last modified 2012-November-17 (18:48)
Goto jj's ugly Homepage