Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete multiple empty lines with sed 1

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
How can I delete multiple (concurrent) empty lines in sed?

If I use "sed '/^$/d'" only the first empty line is deleted when more then one occurs together.

I'm prepared to use perl if I have to but would rather use sed or another Unix command.

Thanks
 
your sed statement worked for me, maybe need to make it global by putting a /g at the end? worth a try hth
 
Tried adding /g but didn't like that. I'm running on Solaris 8 (SunOS 5.8). I usually use ksh but I also tried it using sh & it did the same thing.

Still hoping for a solution ... !
 
Are you sure the lines are really empty? Maybe they have spaces or tabs on them. CaKiwi
 
You're right - don't know why but I can't find a space in vi but when I run the file through od it shows one.

Sorry about that!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top