LoginSignup
0

More than 5 years have passed since last update.

テキストファイルの行末に^Mが表示されているときの一括削除

Posted at

Windowsで作成したファイルを、Macで開くと改行コード周りの関係で生じます。事前にgitの設定で排除しておけばいいという話ではありますが。。。
詳しくは引用元をご参照ください。

gitで管理しているプロジェクトの場合は、以下のように一掃できます。

git grep -l ^M | xargs sed -i '' -e 's/^M//g'

入力の際の注意点は以下の通り。

 ^Mを入力するには、[Ctrl]+[V]キーを押してから、[Ctrl]+[M]キーを押す。^Mは制御コードなので、[^]キーと[M]キーで「^M」と入力しても^Mとは認識されないので注意が必要だ。
via: http://www.atmarkit.co.jp/flinux/rensai/linuxtips/164linendm.html

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
0