How do I combine all lines in a text file into a single line?
tr
as you used it should work and is the simplest -- you just need to output to another file. If you use the input file as output, the result is an empty file as you observed;
cat myfile.txt | tr -d '\n' > oneline.txt
You need to remember some editors terminate a line with \r\n
. For that case, use
cat myfile | tr -d '\r\n'
Here it is. It's another solution and simple easy.
echo $(cat Input.txt) > Output.txt