Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: Deleting (Only) First Blank Line in File Message-ID: <819@ehviea.ine.philips.nl> Date: 1 Jul 90 13:38:52 GMT References: <1651@fallst.UUCP> Reply-To: leo@ehviea.UUCP (Leo de Wit) Distribution: comp Organization: Philips I&E Eindhoven Lines: 28 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. | |Solutions other than those using 'perl' are preferred. Here's a quick and dirty one with sed: sed -n -e ' /^$/{ : back n p b back } p' foo >newfoo All lines before the first empty line are printed by the last 'p' command. Then, at the first empty line, each next line is read in and printed. Leo.