I'm a Java developer and I'm using Ubuntu to develop. The project was created in Windows with Eclipse and it's using the Windows-1252 encoding.
To convert to UTF-8 I've used the recode program:
find Web -iname \*.java | xargs recode CP1252...UTF-8
This command gives this error:
recode: Web/src/br/cits/projeto/geral/presentation/GravacaoMessageHelper.java failed: Ambiguous output in step `CR-LF..data
I've searched about it and get the solution in Bash and Windows, Recode: Ambiguous output in step `data..CR-LF' and it says:
Convert line endings from CR/LF to a single LF: Edit the file with Vim, give the command
:set ff=unix
and save the file. Recode now should run without errors.
Nice, but I've many files to remove the CR/LF character from, and I can't open each to do it. Vi doesn't provide any option to command line for Bash operations.
Can sed be used to do this? How?
recode
produces this error when trying to recode a file with mixed dos (\r\n
- CRLF) and unix (\n
LF) newline coding. Unfortunatellyfromdos
, formerly a binary, is currently an alias to recode which has this problem. – Ardisardisjvim +ex_command_one +ex_command_two ... file
– Unitarianismawk
solution in the answers. – Unmeet