Deleting (Only) First Blank Line in File
Rouben Rostamian
rostamia at umbc3.UMBC.EDU
Sun Jul 1 03:37:34 AEST 1990
In article <1651 at fallst.UUCP> tkevans at 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"}'
--
More information about the Comp.unix.questions
mailing list