remove carriage returns from a text file

What's a fast way to remove carriage returns from a text file so a large file can become one really long line with a space between everyword?

I tried using "J" in VI over and over but I would always get "Internal error: vredraw".  Any ideas?

Thanks.
jewbamaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
perl -i -pe 'BEGIN{$\=" "}chomp;' file
0
rbrCommented:
cat file | awk -v ORS= "{ print $1} > newfile
0
chris_calabreseCommented:
tr < file '
' ' ' > newfile
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

dgrimesCommented:
while read rec
do
   echo $rec"\c" >>outfile
done < inpfile
0
dgrimesCommented:
Found one little problem: Each new record needs to be separated by a space as well:

while read rec
do
   echo $rec" \c" >>outfile
done < inpfile

0
chris_calabreseCommented:
Dgrimes: the problem with this is that the shell 'read' builtin does more than just read the line into a buffer.  Rather it does all kinds of whitespace mangling and also deals with line continuation (\) processing.  The whilespace mangling may actually be a good thing for this particular application, but the line continuation probably is not.  In some shells you can get around this with 'read -r'.
0
dgrimesCommented:
Right, you would want to read with the -r switch. Also, not all shells support this feature. I was using ksh.

Thanks
0
rbrCommented:
jewbama: Did any of the comments solve your problem. If yes post to whom you give the points.
0
mdgreen7Commented:
I use the infozip zip and unzip utilities.

zip temp.zip filename
unzip -oa temp.zip

Or, in a pinch, you can ftp the file:

ftp localhost
login...
asc
get filename filename.new
quit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chris_calabreseCommented:
Hmm, given the suggestions above, these both seem like monumentally bad ways of doing it.
0
dgrimesCommented:
How does this accomplish the intended goal. However, if jewbama doesn't respond, then guess who will get the points!
0
mdgreen7Commented:
Oops.  My bad.  I misread the question.
I stated quick ways to convert from cr/lf to lf....

It was my first reply - I got a little anxious :)  Jeez - "monumentally bad".
0
chris_calabreseCommented:
Monumentally bad because it not only doesn't solve the problem, but requires a lot more effort than other suggestions already listed above that solve the problem 100%.

Don't feel bad about it, just read the comment before posting next time...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.