Linux file character set encoding conversion View file encoding file command file ip.txt View file encoding file command file ip.txtip.txt: UTF-8 Unicode text, with escape sequences 1. Use the iconv command to encode and convert the file content. The iconv command is used to convert the encoding of a specified file. By default, it is output to a standard output device or an output file. Usage: iconv [option...] [file...] the following options are available: input/output format specifications:-f, -- from-code = Name original text encoding-t, -- to-code = Name output code www.2cto.com information:-l, -- list lists all known character set output control:-c ignores invalid characters-o from the output, -- output = FILE output FILE-s, -- silent close warning -- verbose prints progress information -?, -- Help provides the system's help list -- usage provides the simple usage information-V, -- version Printing program version example: iconv-f UTF-8-t gb2312 aaa.txt> examples file. Ii. File Name encoding and conversion because linux is used now, all files in windows are encoded using GBK. Therefore, copying to linux is garbled, and the file content can be converted using iconv. However, many Chinese file names are still garbled. Find a command that can convert the file name encoding, that is, convmv. Convmv command detailed parameters such as convmv-f GBK-t UTF-8 *. mp3 but this command will not convert directly, you can see the comparison before and after conversion. If you want a straight conversion to add the parameter -- notestconvmv-f GBK-t UTF-8 -- notest *. The mp3-f parameter is the encoding before the conversion, and-t is the encoding after the conversion. Do not make a mistake. Otherwise it may be garbled. Another parameter is useful. -R indicates recursively converting all subdirectories in the current directory. 3. The better command line tool, enca, not only intelligently identifies file encoding, but also supports batch conversion. Www.2cto.com 1. install $ sudo apt-get install enca2. check the current file encoding enca-L zh_CN ip.txt Simplified Chinese National Standard; GB2312Surrounded by/intermixed with non-text data3. the conversion command format is as follows $ enca-L current language-x destination encoding file name example to convert all files under the current directory to utf-8enca-L zh_CN- x UTF-8 * enca-L zh_CN file check file encoding enca-L zh_CN-x UTF-8 file convert file encoding to "UTF-8" encoding enca-L zh_CN-x UTF-8 <file1> file2 if you do not want to overwrite the original file, it's easy.