Linux File Batch Encoding Conversion iconv Command

Encoding conversion in Linux can be easily done using the iconv command. It supports both single file and batch processing. The iconv command can convert a file from one known character set to another known character set. Its purpose is to convert text encoding within various international encoding formats.

Shell command for processing a single file:

iconv -t utf-8 -f gb2312 source > target

# -f source encoding # -t target encoding # -l: list known encoding character sets # -o file: specify output file # -c: ignore illegal characters in output # -s: suppress warning messages, but not error messages

Shell command for batch processing:

Batch processing for directories#

find default -type d -exec mkdir -p utf/{} \;

Batch processing for files#

find default -type f -exec iconv -f gb2312 -t utf-8 -o utf/{} \;


Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.