Shell fun with sed and xargs
I cleaned up my life on the road polluted links by running
rg -l 'my path for \[\[Life on the road\]\]' --null | xargs -I % -0 sed -i '' 's/\[\[Life on the road\]\]/life on the road/g' "%"
The breakdown is that
rg -l 'regexPattern'gets a list of files with the pattern in the current directory (my Obsidian vault).--nullputs a null terminator at the end of the list of files output byrg. On the other side of the pipe,-0tellsxargsto expect its arguments to end in null terminators. This allows filenames to contain quotes and importantly, apostrophes'.xargs -I % templateCommandreplaces%insidetemplateCommandwith each file passed via stdinsed -i '' 's/search/replace/g filePathreplaces all instances ofsearchwithreplaceinsidefilePath
Helpful for Programming.