Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!umbc3!rostamia From: rostamia@umbc3.UMBC.EDU (Rouben Rostamian) Newsgroups: comp.unix.questions Subject: Re: Deleting (Only) First Blank Line in File Message-ID: <3545@umbc3.UMBC.EDU> Date: 30 Jun 90 17:37:34 GMT References: <1651@fallst.UUCP> Reply-To: rostamia@umbc3.umbc.edu.UMBC.EDU (Rouben Rostamian) Distribution: comp Organization: University of Maryland, Baltimore County Lines: 23 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? Here are two solutions using awk. In both cases it is assumed that the command is executed as a script, and $1 denotes the input file. Solution 1: awk < $1 'BEGIN{RS=""} { if (NR <= 2 ) print $0; else print "\n" $0; }' Solution 2: Note: Here X denotes a character which does not occur in the input file. Replace with a more suitable character. A control character, such as ^A, may be a good choice. awk < $1 'BEGIN{RS=""} {print $0; ORS=""; RS="X"}' --