정보/Program

[Linux/Shell script] EUC-KR to UTF-8

TELK 2017. 4. 18. 01:51

1. 아래의 파일을 conv2utf8.sh 파일로 저장

#!/bin/bash
for f in $(find -type f -name "*.php" -or -name "*.html")
do
    encoding=`file -i $f | cut -f 2 -d";" | cut -f 2 -d=`
    case $encoding in
    iso-8859-1)
        echo "$f was $encoding"
        iconv -c -f euc-kr -t utf-8 $f > $f.tmp
        mv $f.tmp $f
        ;;
    esac
done

2. chmod +x conv2utf8.sh 명령어로 실행 권한을 줌

3. ./conv2utf8.sh 명령어로 실행