simple (not so?) sed/awk question

simple (not so?) sed/awk question

Post by Tom O'Bri » Fri, 17 Nov 1995 04:00:00



Aloha. I have a simple question that will hopefully be simple to
answer. I want to use the stream editor (sed), or perhaps awk,
to join two contiguous lines in a text file, a sample of which might
look something like this:

This is line one
This is line two
This is line three
etc. etc.

What I  want to do is join all lines which contain the string "two"
(or whatever) with the line directly preceding it. The sample output
would like something like this:

This is line oneThis is line two
This is line three
etc. etc.

Any basic unix trick will do if it can't be done using sed. Please
advise via email as I don't often get a chance to check the newsgroups

as often as I'd like. Thanks!


 
 
 

simple (not so?) sed/awk question

Post by Brian S Hile » Wed, 22 Nov 1995 04:00:00


: Aloha. I have a simple question that will hopefully be simple to
: answer. I want to use the stream editor (sed), or perhaps awk,
: to join two contiguous lines in a text file, a sample of which might
: look something like this:

: This is line one
: This is line two
: This is line three
: etc. etc.

: What I  want to do is join all lines which contain the string "two"
: (or whatever) with the line directly preceding it. The sample output
: would like something like this:

: This is line oneThis is line two
: This is line three
: etc. etc.

: Any basic unix trick will do if it can't be done using sed. Please
: advise via email as I don't often get a chance to check the newsgroups

: as often as I'd like. Thanks!


This should do the trick:
copy is sent via email.

sed -n '
N
/\n.*two/ {
        s/\n//p
        d

Quote:}

P'

-Brian

 
 
 

1. sed/awk - 2 simple question :-)

hi i've a problem with sed/awk

1. problem

i've a file with following content:
---snip
helpc.de
Domain Beantragung hatte DNS-Fehler

hessenbruch-personal.de
Domain Beantragung hatte DNS-Fehler

hms-lamprecht.de
Domain Beantragung hatte DNS-Fehler
..
..
..
---snap

but i need the second line, direct after first line with two tabs
and delete the 3. line... looks like here is the right content

helpc.de                Domain Beantragung hatte DNS-Fehler
hessenbruch-personal.de Domain Beantragung hatte DNS-Fehler
hms-lamprecht.de        Domain Beantragung hatte DNS-Fehler

2. problem

i've many zone files from dns/bind and will in every 10. line of zone
file a new NS A record

my first script does not work right how can talk sed, that uses every
10. line?


2. Jumpstart Question.

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

4. Hi, I have installed Slack 3.3 ( Pentium 133 ,chipset Triton VX ,EIDE ); after the login the hard disk's led remain on ( the led is led on

5. MWAVE How can I disable that chipset??

6. a simple sed question ( there all simple :> )

7. Q: X on laptop IBM ThinkPad 600

8. Simple 'sed', 'awk', 'cut' problem

9. sed/awk (simple)

10. Please help: simple awk|sed problem

11. sed/awk - generating Makefiles (Re: awk processing of Makefile macros)

12. SED & AWK Question...