oddmu-replace - replace text in Oddmu pages
The "replace" subcommand does a search and replace on all the Markdown files in the current directory and its subdirectories.
Replace "Oddmu" in the Markdown files of the current directory:
oddmu replace Oddmu Oddµ
Result:
--- README.md~ +++ README.md (diff omitted) 1 file would be changed. This is a dry run. Use -confirm to make it happen.
This is the equivalent of using *sed*(1) with the --quiet, --regexp-extended, --in-place=~ and --expression command with the s command "s/regexp/replacement/g" except that it prints a unified diff per default instead of making any changes and the regexp rules differ slightly.
The search is case-sensitive. To make it case-insensitive, search for a regular expression that sets the case-insensitive flag, e.g. "(?i)oddmu".
Consider creating a backup before doing replacements!
The following Bash script creates a copy of the current directory using hard links. If you're in a directory called "wiki", it creates a sibling directory called "wiki-2023-11-24" (using the current date) full of links. This takes little space and time. It works as a backup as long as you don't use an application that edits files in place. Most programs overwrite old files by creating new files with the same name, so you should be safe.
#!/usr/bin/bash d=$(basename $(pwd)) t=$(date --iso-8601) echo Creating a snapshot of $d in ../$d-$t rsync --link-dest "../$d" --archive . "../$d-$t/"
The above wouldn't work for database files, for example. There, the database changes the file in place thus the file is changed in the backup directory as well. For Oddmu and the usual text editors, it works. If you use Emacs, don't set *backup-by-copying*, *backup-by-copying-when-linked* and related variables.
oddmu(1), oddmu-search(7)
Maintained by Alex Schroeder alex@gnu.org.