Deleting (Only) First Blank Line in File

Rouben Rostamian rostamia at umbc3.UMBC.EDU
Sun Jul 1 00:20:09 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?

I do not know to do this in sed, but here's how it can be done in ed:

1. Create a file "mystrip" containing:
ed $1 << 'EOF'
/^$/d
w
q
'EOF'

2. chmod u+x mystrip

3. To strip the first blank line in file "try", do
   mystrip try



More information about the Comp.unix.questions mailing list