I try to find all text files encoded iso-8859-1 and convert them to UTF-8. My attempt:
find . -name '*.txt' | xargs grep 'iso-8859-1' | cut -d ':' -f1 |
xargs iconv -f ISO-8859-1 -t UTF-8 {} > {}.converted
The problem (obvious) is that the last variable substitution will not work, because it {}occurs after the redirect and does not belong xargs. How can I get only one file with a name {}.converted, not a.txt.converted, b.txt.convertedetc. How can I do this job?
Note. I am doing this on Cygwin, where iconv does not seem to support it -o.
source
share