5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CRLFが含まれているファイルを手っ取り早く探して置換

Last updated at Posted at 2013-12-12

fileコマンドに聞いてみる

例えばカレント配下の*.javaファイルなら

find . -name '*.java' | xargs file | grep CRLF

見つかった結果を一括で置換したい場合は

find . -name '*.java' | xargs file | grep CRLF | awk -F: '{print $1}' | xargs dos2unix

など。

注意

fileコマンドに依存するので万能な方法じゃないです。
例えばxmlファイルとかは
XML document text
とか言われるだけで改行コードの情報を教えてくれません。

参考

bash - How do you search for files containing dos line endings (CRLF) with grep on Linux? - Stack Overflow

5
6
0

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
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?