如何在目录的每个文件中将制表符转换为空格? [英] How can I convert tabs to spaces in every file of a directory?
本文介绍了如何在目录的每个文件中将制表符转换为空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将目录的每个文件中的制表符转换为空格(可能是递归的)?
How can I convert tabs to spaces in every file of a directory (possibly recursively)?
另外,有没有办法设置每个标签的空格数?
Also, is there a way of setting the number of spaces per tab?
推荐答案
警告:这会破坏您的存储库.
这个会破坏二进制文件,包括
svn
、.git
下的二进制文件!使用前请阅读评论!
Warning: This will break your repo.
This will corrupt binary files, including those under
svn
,.git
! Read the comments before using!
找到.-iname '*.java' -type f -exec sed -i.orig 's/ //g' {} +
原始文件保存为[filename].orig
.
用您要查找的文件类型的文件结尾替换*.java".这样您就可以防止意外损坏二进制文件.
Replace '*.java' with the file ending of the file type you are looking for. This way you can prevent accidental corruption of binary files.
缺点:
- 将替换文件中所有位置的选项卡.
- 如果您在此目录中碰巧有 5GB 的 SQL 转储,则需要很长时间.
这篇关于如何在目录的每个文件中将制表符转换为空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文