Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!cam-cl!tmal From: tmal@cl.cam.ac.uk (Mark Lomas) Newsgroups: comp.sources.bugs Subject: Re: inconsistent behavior of sed Summary: This behaviour is deliberate Keywords: substitute delete botched confusion Message-ID: <839@scaup.cl.cam.ac.uk> Date: 12 Jul 89 12:39:25 GMT References: <377@proexam.UUCP> Sender: news@cl.cam.ac.uk Reply-To: tmal@cl.cam.ac.uk (Mark Lomas) Organization: U of Cambridge Comp Lab, UK Lines: 21 In article <377@proexam.UUCP> glen@proexam.UUCP (Glen Brydon) writes: > sed 's/.*/&/p;d' (this is a minimal condensation) > >It seems obvious to me that this should simply pass all information, >however, some versions of sed actually delete. This seems to be always >true of sysV sed and recently true of bsd sed (post 4.0 sunOS). The manual entry for sed which is supplied with HP-UX, a System V derivative, indicates that this change in behaviour is deliberate. In previous versions of sed the `p' flag at the end of a substitute command caused the result of the substitution to be printed. In the current version the state of the `-n' switch is also checked. Only if output is disabled by default will the `p' flag have any effect. This means that the example which you gave may be corrected by adding the `-n' switch to the command line: sed -n 's/.*/&/p;d' Mark Lomas (tmal@cl.cam.ac.uk)