$ cat input.txt
aaaa
あああ
いいい
$ file input.txt
input.txt: Non-ISO extended-ASCII text, with CRLF line terminators
$ ./dos2unix.sh input.txt output.txt
$ file output.txt
output.txt: UTF-8 (with BOM) text
Last active
August 29, 2015 14:26
-
-
Save ubnt-intrepid/07169f102c3531fa62f6 to your computer and use it in GitHub Desktop.
Shift-JIS から UTF-8 (with BOM) に変換するスクリプト (perl, shell script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| perl -MEncode -pe 'BEGIN{print "\xEF\xBB\xBF"} s/\r\n/\n/g;Encode::from_to($_,"shiftjis","utf-8");' $1 > $2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ # リポジトリに登録されているファイルから改行コードにCRLFが含まれているものを取り出す | |
| $ git grep --cached --full-name --name-only -I $'\r' | |
| path/to/hoge.txt | |
| path/huga.txt | |
| ... | |
| $ # filelist内に記されたファイルの改行コードをCRLF->LFに変換 | |
| $ cat filelist | while read line; do perl -i -pe 's/\r\n/\n/g;' "$file"; done |
Author
ubnt-intrepid
commented
Aug 4, 2015
- clang-format
- auto crlf false
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment