Monday, August 18, 2008

[Bash] Convert files from ISO-8859-1 to UTF-8 based on output from maven install

I had a number of files in ISO-8859-1 that could not compile in "maven install" due to maven-compiler-plugin containing "UTF-8". The solution was to create a one-liner in linux, taking the output from the maven install and convert each files encoding:



for i in ` mvn install | grep ".java" | cut -d ":" -f 1`; do iconv --from-code=ISO-8859-1 --to-code=UTF-8 $i > tmp.java; mv tmp.java $i; done


Enjoy!

No comments: