Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-29-2008, 03:05 PM   #1
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 441

Rep: Reputation: 30
Using sed to replace newling with space

Can you give me an expressing that will replace newline with space?
Old 05-29-2008, 03:13 PM   #2
Registered: Jul 2005
Location: Florida
Distribution: Red Hat
Posts: 34

Rep: Reputation: 15
You can try this....not sure if it will work for you or not.
open your file with vi.
put it in escape mode (hit escape a couple of times)
type :1,$s/\n/ /g
press enter
Old 05-29-2008, 03:32 PM   #3
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
I've always had trouble getting sed to do this elegantly, other than doing this:
sed 's/
/\ /g' infile > outfile
I generally use tr instead:
tr "\n" " " < infile > outfile


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sed - How do you replace end of line with a space pppaaarrrkkk Programming 7 02-07-2011 11:27 AM
sed search replace tomerbd1 Linux - General 9 04-10-2008 04:31 AM
How do I replace ' with sed.... @ngelot Linux - Newbie 2 11-02-2007 07:04 PM
How can I replace this string with another using sed? dave4545 Programming 7 01-27-2006 10:58 AM
Sed - suitable to replace CR LF? J_Szucs Programming 3 05-12-2003 06:03 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration