如何转换选项卡,以空间上的使用bash许多文件 [英] how do i convert tabs to spaces on many files with bash

查看:86
本文介绍了如何转换选项卡,以空间上的使用bash许多文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何转换选项卡空间中的所有.js文件在目录中的一个命令?

How can I convert tabs to spaces in in all .js files in a directory in one command?

推荐答案

这将制表符转换为四个空格:

This would convert tabs to four spaces:

find /path/to/directory -type f -iname '*.js' -exec sed -ie 's|\t|    |g' '{}' \;

在sed中之间的更改部分空间在未来两 | 有你喜欢的空间自定义数字

Change the space part in sed between the next two | to have a custom number of spaces you like.

另一种方法是将所有文件,一次处理一个电话SED +

Another way is to process all files to one sed call at once with +:

find /path/to/directory -type f -iname '*.js' -exec sed -ie 's|\t|    |g' '{}' '+'

只是考虑的参数可能限制由系统的命令。

Just consider the possible limit of arguments to a command by the system.

这篇关于如何转换选项卡,以空间上的使用bash许多文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆