如何删除尾随递归所有文件的空白? [英] How to remove trailing whitespace of all files recursively?
本文介绍了如何删除尾随递归所有文件的空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你怎么能删除所有整个项目的尾随空白?开始在根目录下,并从所有文件夹中的所有文件删除尾随空白。
How can you remove all of the trailing whitespace of an entire project? Starting at a root directory, and removing the trailing whitespace from all files in all folders.
另外,我想对能够直接修改该文件,而不是只打印所有到标准输出。
Also, I want to to be able to modify the file directly, and not just print everything to stdout.
推荐答案
下面是一个OS X> = 10.6雪豹的解决方案。
Here is an OS X >= 10.6 Snow Leopard solution.
它忽略git的和.svn目录及其内容。此外,它不会留下一个备份文件。
It Ignores .git and .svn folders and their contents. Also it won't leave a backup file.
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i '' -E "s/[[:space:]]*$//"
这篇关于如何删除尾随递归所有文件的空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文