Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Am trying to convert several SQL files from ISO8859-1 to UTF-8

Am doing the following command:

iconv -f ISO_8859-1 -t UTF-8 *.sql

What i get is an output of their content to the terminal which is very long and after ending the output they do not convert. They stay the same. I wish to be able to convert and not see the output.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

iconv defaults to sending its output to stdout, which explains the behaviour of what you saw. You can direct the output to a file using the -o option, but that will only generate a single output file, and probably won't help you update the files in place. Perhaps try something like this:

for file in *.sql; do
    iconv -f ISO-8859-1 -t UTF-8 -o "$file".utf "$file" && mv "$file".utf "$file"
done

That will convert each file and store the result in a temporary file, moving it to the original file name if the conversion was successful.

share|improve this answer
    
That is some smart script there James. Thank you very much. –  Luis Alvarado May 10 '11 at 1:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.