How to replace U+00A0 NBSP by regular space in a directory of Markdown files
If you have a directory with Markdown files that contain non-breaking spaces (U+00A0
, NBSP) and you want to replace them with regular spaces (U+0020
), you can use the following command in a Unix-like terminal:
This assumes your files are UTF-8 encoded!. I recommend to manage your Markdown files using Git so you can easily revert the changes if something goes wrong.
replace_nbsp.sh
find . -type f -name "*.md" -exec sed -i 's/\xc2\xa0/ /g' {} +
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow