Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!athena.mit.edu!watcher From: watcher@athena.mit.edu (chris ross) Newsgroups: comp.unix.questions Subject: need help with sed "pattern space" Message-ID: <12583@bloom-beacon.MIT.EDU> Date: 11 Jul 89 05:19:10 GMT Sender: daemon@bloom-beacon.MIT.EDU Reply-To: watcher@athena.mit.edu (chris ross) Distribution: na Organization: Massachusetts Institute of Technology Lines: 30 hi. Got a few questions for you sed sharks... sed claims that it "cyclically copies a line of input into a pattern space (unless there is something left after a D command), applies in sequence all commands whose addresses select that pattern space, and at the end of the script copies the pattern space to the standard output (except under -n) and deletes the pattern space" 1. Given the above description, and reading from stdin, why do simple scripts like "sed s/a/b/g" not produce output until the _second_ input line has been entered? 2. It seems to me that a script like "sed '/foo/,/bar/ d'" needs to retain the pattern space for an arbitrary number of input lines. Does the phrase "start the next cycle" in the d command documentation mean "start the next cycle NOW, without checking other addresses, doing output, or clearing the pattern space?" If not, why doesn't a p command after the d command print the growing pattern space as many times as there are lines retained by /foo/,/bar/ ? 3. Why doesn't "sed '/^$/,/^$/ D'" (note UPPERcase D) convert multiple consecutive blank lines to a single blank line? Obviously, I'm thinking about the pattern space in the wrong way. Can anyone point me in the right direction? thanx _____________________________________ chris ross <0> watcher@athena.mit.edu