Forrest logo
back to the iconv tool

iconv:tldr:6fd7b

iconv: Convert file to the current locale's encoding, and output to a file.
$ iconv -f ${from_encoding} ${input_file} > ${output_file}
try on your machine

The command iconv -f ${from_encoding} ${input_file} > ${output_file} is used to convert the encoding of a text file from one format to another.

Here is a breakdown of the command:

  • iconv: This is the name of the command-line tool used for character encoding conversion.
  • -f ${from_encoding}: This specifies the encoding of the input file. ${from_encoding} is a placeholder that should be replaced with the actual encoding name (e.g., UTF-8, ISO-8859-1, etc.).
  • ${input_file}: This is the name or path of the input file that needs to be converted. ${input_file} is another placeholder that should be replaced with the actual file name or path.
  • > ${output_file}: This redirects the output of the iconv command to a specified file instead of displaying it on the terminal. ${output_file} is a placeholder that should be replaced with the actual file name or path where you want the converted output to be saved.

For example, if you wanted to convert a file named input.txt from UTF-8 encoding to ISO-8859-1 encoding and save the output to a file named output.txt, the command would look like this:

iconv -f UTF-8 input.txt > output.txt

After running this command, the input.txt file will be converted from UTF-8 encoding to ISO-8859-1 encoding, and the converted content will be saved to the output.txt file.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the iconv tool