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
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
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.
and your life will be happier.
lastmod (uses replace)
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
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.
jj (Jörg Arndt)
Last modified 2018-May-31 (17:57)
jj's ugly Homepage