delete blank lines with sed | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

delete blank lines with sed

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-30-2005
tmxps's Unix or Linux Image
tmxps tmxps is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 2 November 2005, 5:11 PM EST
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
delete blank lines with sed

I have a text file with blank lines fullfilled with spaces and others only containing the "Enter" caracter, the \012.

I would like to eliminate all them with the sed command.

Is it possible?

making: sed '/^$/d' <file should delete the blank lines but doesn't work for the lines that only have \012.

Thanks in advance.
Sponsored Links
    #2  
Old Unix and Linux 10-30-2005
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 26 March 2015, 3:50 PM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 444 Times in 263 Posts
Try this:
sed '/^ *$/d'
The Following User Says Thank You to Perderabo For This Useful Post:
vel4ever (01-10-2012)
Sponsored Links
    #3  
Old Unix and Linux 08-21-2007
buldir's Unix or Linux Image
buldir buldir is offline
Registered User
 
Join Date: Aug 2007
Last Activity: 16 January 2008, 1:46 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
This thread is ancient, but I wanted to say thanks to Perderabo. Your solution helped me out big time.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Delete blank lines in a file rkumar28 Shell Programming and Scripting 4 05-07-2012 06:38 PM
Delete blank lines, if blank lines are more than one using shell anil8103 Shell Programming and Scripting 5 05-10-2011 07:21 PM
Why cant i delete blank lines? omgsomuchppl Shell Programming and Scripting 2 12-09-2008 07:34 AM
delete blank lines from a file sachin.gangadha UNIX for Dummies Questions & Answers 2 12-04-2007 06:13 PM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 06:36 AM



All times are GMT -4. The time now is 05:23 AM.