Urgent VI/SED question 
Author Message
 Urgent VI/SED question


> Does anyone know how to find and delete new-line in VI?


> I'm trying to eliminate newlines after a particular pattern in
> a very large file.

Forget about "eliminating newlines." Think in terms of text, not
characters. What you really want to do is join a line that matches
a pattern with the line that immediately follows it. In other words,
you want to print those lines that match some pattern WITHOUT a
newline, and print those lines that do NOT match the pattern WITH
a newline.


    /a pattern/ { printf("%s", $0); next }
                { print }


        if (/a pattern/)
            printf("%s",   $0)
            printf("%s\n", $0)


    { printf("%s%s", $0, /a pattern/ ? "" : "\n") }

You can do this in vi or with sed, but this is comp.lang.awk. :-)

Jim Monty

http://www.*-*-*.com/ ~monty/
Tempe, Arizona USA

Sun, 19 Aug 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 


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

3. Awk/Sed Filehandler question

4. A very simple question on SED or AWK for a GURU, and an enjoyable problem

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

6. A question about sed

7. a sed question

8. SED question

9. awk or sed: basic? question

10. Sed Question

11. 2 questions from book sed and awk programming

12. Stupid question...Is sed in gawk??


Powered by phpBB® Forum Software