Skip to content

Instantly share code, notes, and snippets.

@blue1st
Created October 8, 2015 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blue1st/7d98d466f442cc39048f to your computer and use it in GitHub Desktop.
Save blue1st/7d98d466f442cc39048f to your computer and use it in GitHub Desktop.
ファイルのエンコードを変更するワンライナー
perl -MEncode -i -nle 'Encode::from_to($_,"utf8","cp932");print $_¥r¥n' [FILE]
# -MオプションでEncodeモジュールを指定
# -iオプションで一時ファイルを作るよう指定
# -nで引数のファイルを展開して一行ずつ実行
# -lオプションでchompして要らない改行を取り除く
# エンコード変換して新たな改行コードを加えて出力する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment