Bash – join xargs’ output by newlines

bashxargs

I want to join output of the xargs output by new lines. I do this:

find . -name '*.txt' | xargs -n 1 iconv -f UTF-16 | ...other-commands...

I take one file at a time and convert it to UTF-8 (the system locale). All of the *.txt are one-liners without newline character at the end. So the output of xargs is a mess of text.

How do you separate items of xargs output by \n?

Best Answer

An ugly solution:

find . -name '*.txt' | { xargs -n 1 -I_ bash -c 'iconv -f UTF-16 _;echo '; }| ...other-commands...