如何去除一个目录中 Markdown 文件的行尾空白
如果你有一个装满 Markdown 文件的目录,并希望去除这些文件中每一行的行尾空白,可以使用以下 shell 命令。该命令使用 find 查找所有 .md 文件,并使用 sed 原地编辑,去除任何行尾空白。
我建议使用 git 来跟踪更改,这样如果出现问题,你可以轻松地还原。
trim-trailing-whitespace.sh
find . -type f -name "*.md" -exec sed -i -E 's/[[:space:]]+$//' {} +If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow