0

1 つのコマンドで、ディレクトリ内のすべての .js ファイルでタブをスペースに変換するにはどうすればよいですか?

4

3 に答える 3

1

This would convert tabs to four spaces:

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

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

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.

于 2013-08-27T15:36:20.893 に答える