commit 047a5cfbd8f2032a8da6c5cca6e7692d43a6eee3 parent 27d3b6913befb95803c4602b6f1ab238888f0cd3 Author: Antoine Amarilli <a3nm@a3nm.net> Date: Sat, 23 Dec 2023 15:03:37 +0100 wikimv Diffstat:
wikimv | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/wikimv b/wikimv @@ -0,0 +1,24 @@ +#!/bin/bash + +FROM="$1" +TO="$2" +FROMF="$HOME/todo/wiki/$FROM" +TOF="$HOME/todo/wiki/$TO" + +if [ -f $TOF ] +then + echo 'target already exists' + exit 42 +fi + +mv "$FROMF" "$TOF" || (echo 'fail move'; exit 42) + +# now replace all links in files with match + +cd "$HOME/todo/wiki" +grep -RlF "[$a]" | while read a; do + if [ -f $a ]; then + sed -i "s/\[$FROM\]/\[$TO\]/g" $a + fi +done +