LoginSignup
7
5

More than 5 years have passed since last update.

ディレクトリ内のすべてのファイルをCRLF→LFに変換する

Last updated at Posted at 2015-02-06

いつものようにgit addしたら改行コマンド周りでエラーが。

$ git add .
fatal: CRLF would be replaced by LF in (file)

そのため以下のコマンドでLFに変換した。
findコマンドで、カレントディレクトリ配下の、ディレクトリ以外のファイルを検索。
xargsでnkfコマンドにぶっ込む。

find . -type f | xargs nkf -Lu --overwrite

途中、

(file): Too many open files

といわれた。
ファイルディスクリプタの上限数に当たっているらしいが、
上限の変更がうまくいかなかったため、xargsでわたす引数の数に制限をかけることで対応した。
※コメントいただいた @syohex さんありがとうございます!!!

find . -type f | xargs -n 256 nkf -Lu --overwrite
7
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5