LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (http://www.linuxquestions.org/questions/general-10/)
-   -   sed command options (http://www.linuxquestions.org/questions/general-10/sed-command-options-4175423437/)

Boopathiraj 08-22-2012 09:41 AM

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.

acid_kewpie 08-22-2012 09:44 AM

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' ' '

Boopathiraj 08-23-2012 06:19 AM

Quote:

Originally Posted by acid_kewpie (Post 4761144)
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

pixellany 08-23-2012 07:09 AM

That does not work on a Unix / Linux file.

What is the format of the file(s) you are working with?

pixellany 08-23-2012 07:16 AM

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......;)

Boopathiraj 09-27-2012 03:11 AM

Quote:

Originally Posted by pixellany (Post 4762030)
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.


All times are GMT -5. The time now is 09:26 PM.