How to change encoding in many files?

前端 未结 4 941
甜味超标
甜味超标 2020-12-17 03:10

I try this:

find . -exec iconv -f iso8859-2 -t utf-8 {} \\;

but output goes to the screen, not to the same file. How to do it?

4条回答
  •  猫巷女王i
    2020-12-17 03:51

    I found this method worked well for me, especially where I had multiple file encodings and multiple file extensions.

    Create a vim script called script.vim:

    set bomb
    set fileencoding=utf-8
    wq
    

    Then run the script on the file extensions you wish to target:

    find . -type f \( -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.css" -o -iname "*.less" -o -iname "*.js" \) -exec vim -S script.vim {} \;
    

提交回复
热议问题