How do I combine all lines in a text file into a single line?
- by John
I want to get all lines in a text into one line. I'm a beginner at coding trying to learn by doing. I've spent four hours trying to solve this problem. I know there's a simple solution to this problem. Here's what I've been trying.
sed -e 'N;s/\n//' myfile.txt #Does nothing
sed -e :a -e N -e 's/\n/ /' -e ta myfile.txt #output all messed up and I can't make head nor tail of the syntax
cat myfile.txt | tr -d '\n' myfile.txt # Deletes all lines
Here's the text file:
500212
262578-4-4
23200
GRIFFITH LABORATORIES LTD
GRIFFITH LABORATORIES
SOUTH DUBLIN COUNTY COUNCIL
OFFICE
OFFICE (INDUSTRIAL)
List Rateable
2 Pineview Industrial Estate
Firhouse Road
Knocklyon
31 Dec 2007
01 Jan 2008"
I can't figure out where I've gone wrong....