Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

delete blank lines with sed

Shell Programming and Scripting


Closed    
 
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 February 2016, 12:31 PM EST
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 465 Times in 269 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 07:38 PM
Delete blank lines, if blank lines are more than one using shell anil8103 Shell Programming and Scripting 5 05-10-2011 08:21 PM
Why cant i delete blank lines? omgsomuchppl Shell Programming and Scripting 2 12-09-2008 08:34 AM
delete blank lines from a file sachin.gangadha UNIX for Dummies Questions & Answers 2 12-04-2007 07:13 PM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 07:36 AM



All times are GMT -4. The time now is 06:07 AM.