LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-29-2008, 03:05 PM   #1
binarybob0001
Member
 
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
linux-who?
Member
 
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
pwc101
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:
Code:
sed 's/
/\ /g' infile > outfile
I generally use tr instead:
Code:
tr "\n" " " < infile > outfile
 
  


Reply


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


All times are GMT -5. The time now is 07:48 PM.

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