bash - Transforming Text File into One Line -


i have set of large text files. example, war , peace project gutenburg. need make text fits 1 (obviously long) line in text file, i.e. no line breaks. using bash on os x.

so far have tried several different commands transform file (pg2600.txt) new file (output.txt) no avail.

tr -d '\n' <pg2600.txt > output.txt seemed promising when open in text editor, line breaks still there.

the end goal transform this:

"madame, doubt ability before such audience," said he, smilingly inclining head. 

into

"madame, doubt ability before such audience," said he, smilingly inclining head. 

since text files may have \r, unix operating systems may not recognize them. use instead:

tr -d '\r' < input > output 

or in case remove newlines use:

tr -d '\r\n' < input > output 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -