sed question 
Author Message
 sed question

Sorry to post a sed question here since I cannot find a sed newsgroup.

Here is my question:

I have a file with several lines, say

first line
second line
third line

How can I concatenate the three lines in one line?

Any suggestions?

Thanks in advance!

Yao



Sat, 24 Jul 1999 03:00:00 GMT  
 sed question

: Sorry to post a sed question here since I cannot find a sed newsgroup.
: Here is my question:
: I have a file with several lines, say
:       first line
:       second line
:       third line
: How can I concatenate the three lines in one line?
: Any suggestions? Thanks in advance!

Sed questions are usually directed to comp.unix.shell, but here is OK.
Do you wish _all_ lines in the file to be concatenated? Three lines each?
The first three lines? All these alternatives require different solutions.

sed 'N;N;s/\n//g' file

for the simplest case.

-Brian
--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__



Sat, 24 Jul 1999 03:00:00 GMT  
 sed question


writes:

-Sorry to post a sed question here since I cannot find a sed newsgroup.
My sed's a little week, but I think you use the H command.
-
-Here is my question:
-
-I have a file with several lines, say
-
-first line
-second line
-third line
-
-How can I concatenate the three lines in one line?
I would do this:
        paste -s -d'\t\t\n' file > final # *untested*
-
-Any suggestions?
There's an awk solution, but why would anyone suggest
that in this group :-?
-
-Thanks in advance!
-
-Yao

Martin Cohen, AMSAA-North, Custom House Rm 800
Philadelphia, PA 19106-2976 (215) 597-8377 DSN 444-3808



Mon, 26 Jul 1999 03:00:00 GMT  
 sed question


Quote:

>  Sorry to post a sed question here since I cannot find a sed newsgroup.

>  Here is my question:

>  I have a file with several lines, say

>  first line
>  second line
>  third line

>  How can I concatenate the three lines in one line?

Well, your question doesn't necessarily require sed. I'd use tr:

tr -s "\n" " " infile > outfile

Cheers,

gary         -=- visit The C Programmers' Reference -=-
          http://users.southeast.net/~garyg/C_ref/C/c.html
               The AVENUE Programmers' Class Requests
             http://users.southeast.net/~garyg/class.htm



Thu, 29 Jul 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. a sed question

2. SED question

3. Sed Question

4. Urgent VI/SED question

5. This might be a sed question

6. A sed question

7. awk vs. sed question

8. A sed question

9. How to do this.. (SED question)

10. sed question: unreliable "/^$/d" ?

11. Newbie awk (sed??) question, regular expressions

12. Awk/Sed Filehandler question

 

 
Powered by phpBB® Forum Software