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? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -