Replace a property name across hundreds of Markdown files in a single operation - for example, renaming Updated: to Date: throughout an entire KB4IT document repository.
sed (required for the -i in-place flag)Before making any changes, list every file that contains the old property name:
grep -rl 'Updated:' /path/to/docs --include="*.md"
Review the output to confirm the scope matches your expectations.
If all files are in one flat directory, run:
sed -i 's/Updated:/Date:/g' *.md
The -i flag edits each file in-place. The g flag replaces all occurrences per line, though a property name typically appears only once per file.
For a directory tree, use find with the + terminator to batch files into a single sed invocation (more efficient than one process per file):
find /path/to/docs -name "*.md" -exec sed -i 's/Updated:/Date:/g' {} +
Confirm no occurrences of the old name remain:
grep -r 'Updated:' /path/to/docs --include="*.md"
An empty result means the rename is complete.
WARNING: The
-iflag modifies files permanently. Ensure you have a backup or the repository is under version control (e.g. Git) before running the command.TIP: On macOS, GNU
sedis not the default. Either install it via Homebrew (brew install gnu-sed) and usegsed, or append a backup suffix:sed -i '' 's/Updated:/Date:/g' *.md.