LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2009, 07:40 AM   #1
kbmukesh
LQ Newbie
 
Registered: Jun 2008
Posts: 6

Rep: Reputation: 0
Remove a new line character


Hi,

i have a file which looks like this:

49888 Incorrect location
2009-03-30
444789 Missing issue
2009-04-12
658971 Resolution
2008-12-08

and expect the output to be like this:

49888 Incorrect location 2009-03-30
444789 Missing issue 2009-04-12
658971 Resolution 2008-12-08

please help me out. i tried sed new line removal but it appends everything to a single line.
 
Old 04-09-2009, 07:44 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Welcome to LQ!

Post what you have tried.
 
Old 04-09-2009, 08:37 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try the N command of sed to read the next line and add it to the pattern space, separated by newline. Then change the newline with a space and it will output every two lines in a single one:
Code:
sed '$!N;s/\n/ /' file
 
Old 04-13-2009, 12:41 AM   #4
kbmukesh
LQ Newbie
 
Registered: Jun 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Thx colucix. That's exactly what i was looking for.
 
  


Reply



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
Remove last character from file/string linuxchump Programming 34 06-08-2009 04:01 AM
How do I remove everything after a certain character in text files? SentralOrigin Linux - General 3 01-14-2009 02:15 PM
How do I remove lines that have more than one of a certain character in them? SentralOrigin Linux - General 2 01-14-2009 01:40 PM
Remove rightmost character from bash gn00kie Programming 9 01-29-2008 12:08 AM
remove the 'd' character from the end of string powah Programming 6 11-08-2007 07:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration