Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!quando!omerzu From: omerzu@quando.quantum.de (Thomas Omerzu) Newsgroups: comp.unix.questions Subject: Re: Deleting (Only) First Blank Line in File Message-ID: <1607@quando.quantum.de> Date: 1 Jul 90 22:15:37 GMT References: <1651@fallst.UUCP> <819@ehviea.ine.philips.nl> Reply-To: omerzu@quando.quantum.de (Thomas Omerzu) Distribution: comp Organization: Quantum GmbH, Dortmund, W-Germany Lines: 29 In article <819@ehviea.ine.philips.nl> leo@ehviea.UUCP (Leo de Wit) writes: >In article <1651@fallst.UUCP> tkevans@fallst.UUCP (Tim Evans) writes: >|Can someone help me to delete the _first_ occurring blank line of a file >|(whereever it occurs) without deleting subsequent ones? >| >|You'd think the following would work, but it doesn't: >| >| sed 's/^$//1' foo > newfoo > >Sure. It isn't valid sed syntax. NO! It is valid sed syntax. The reason, that this does not work as supposed is different: the pattern /^$/ matches any empty line. On the first occurency (indicated by '1'), this emptiness is replaced by //, i.e. nothing, and the line is p r i n t e d. And this is the actual problem: /^$/ does n o t include the '\n', which ist created by printing the empty line. -- *-----------------------------------------------------------------------------* Thomas Omerzu UUCP: ...!unido!quando!omerzu / omerzu@quando.uucp Quantum GmbH, Bitnet: UNIDO!quando!omerzu / omerzu%quando@UNIDO(.bitnet) Dortmund, Germany Internet: omerzu@quando.quantum.de