LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 08-22-2012, 09:41 AM   #1
Boopathiraj
LQ Newbie
 
Registered: Jul 2012
Posts: 9

Rep: Reputation: Disabled
sed command options


Hi ,

Greetings !!!

I am searching for Linux Command to replace carriage return to space.

ie..

Previous format
1
2
3
4
5


After commanding the format should be

1 2 3 4 5 6 7 8


Kindly help in resolving this.

I guess sed command will help this..Please suggest.
 
Old 08-22-2012, 09:44 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,373

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
sed isn't really that useful as it operates on lines, delimited by default by a newline, so doesn't see them. tr is easier...

cat file | tr '\n' ' '
 
Old 08-23-2012, 06:19 AM   #3
Boopathiraj
LQ Newbie
 
Registered: Jul 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
sed isn't really that useful as it operates on lines, delimited by default by a newline, so doesn't see them. tr is easier...

cat file | tr '\n' ' '

Thanks for your response..
I tried and it is fine..
In the mean time i find some other solution which also helped...

that is ..

sed "s/\r//" file1 > file2
 
Old 08-23-2012, 07:09 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
That does not work on a Unix / Linux file.

What is the format of the file(s) you are working with?
 
Old 08-23-2012, 07:16 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Assuming a Unix/Linux file:
Code:
sed -r -n ':1; ${s/\n/ /gp; q};N;b1' filename > new filename
The tr option seems simpler.......

For the record: I am not the only SED nut-case here. member "firstfire" has topped anything I EVER came up with......
 
Old 09-27-2012, 03:11 AM   #6
Boopathiraj
LQ Newbie
 
Registered: Jul 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pixellany View Post
Assuming a Unix/Linux file:
Code:
sed -r -n ':1; ${s/\n/ /gp; q};N;b1' filename > new filename
The tr option seems simpler.......

For the record: I am not the only SED nut-case here. member "firstfire" has topped anything I EVER came up with......



Hi ,


Sorry for delay and thanks for your update.
 
  


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
[SOLVED] sed gives :sed: -e expression #1, char 1: unknown command: `'' samasat Linux - Newbie 10 06-09-2012 05:31 PM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
Sed command - command garbled errror gauavmahesh Linux - Newbie 3 03-30-2012 10:04 PM
[SOLVED] different options in sed dinakumar12 Linux - Newbie 3 09-04-2011 08:02 PM
sed options niidea Programming 2 09-20-2003 01:15 PM


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

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