If on a GNU system, look into the
--delimiter argument to
xargs. Since your input is separated by newlines, you needn't rely on quoting at all, or use any additional tools:
cat files.txt | xargs --delimiter=\\n printf "<%s>"
files.txt contains your input:
line number 1
line number 2
line number 3
Gives the output:
<line number 1><line number 2><line number 3>
NB: You do not need to store your input in a file and use
cat; you may of course pipe directly from another program. I used
cat in my example due to its ubiquity and utility in creating self-contained examples such as this.
Even better (and recommended by the
xargs manual) is to have your output program separate the entries by the NUL (
\0) instead of a newline, and use the
--null option instead of
--delimiter, but as long as your input strings will never themselves contain newlines, you're OK with the above approach.