Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-03-2010
Registered User
 

Join Date: Aug 2009
Location: Dhaka,Bangladesh
Posts: 181
Thanks: 38
Thanked 3 Times in 3 Posts
What's the command to remove empty lines with sed?


Code:
3

10 20

10 100

100 10000

Output:

Code:
3
10 20
10 100
100 10000



---------- Post updated at 07:59 AM ---------- Previous update was at 07:56 AM ----------

sed '/^$/d' file doesn't work.

Last edited by cola; 09-03-2010 at 10:23 PM..
Sponsored Links
    #2  
Old 09-03-2010
Resident BOFH
 

Join Date: Dec 2007
Posts: 1,100
Thanks: 2
Thanked 76 Times in 74 Posts
the empty lines are removed in your output
Sponsored Links
    #3  
Old 09-03-2010
Registered User
 

Join Date: Aug 2009
Location: Dhaka,Bangladesh
Posts: 181
Thanks: 38
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by frank_rizzo View Post
the empty lines are removed in your output
No,file is the input file.
    #4  
Old 09-03-2010
Resident BOFH
 

Join Date: Dec 2007
Posts: 1,100
Thanks: 2
Thanked 76 Times in 74 Posts
oh so you mean output is your desired output. do those lines have tabs or spaces? if so they wont match that pattern.
Sponsored Links
    #5  
Old 09-03-2010
Registered User
 

Join Date: Aug 2009
Location: Dhaka,Bangladesh
Posts: 181
Thanks: 38
Thanked 3 Times in 3 Posts
No tab/spaces.
Sponsored Links
    #6  
Old 09-03-2010
Resident BOFH
 

Join Date: Dec 2007
Posts: 1,100
Thanks: 2
Thanked 76 Times in 74 Posts
Quote:
Originally Posted by cola View Post
No tab/spaces.
i dont believe you. post the output of this command


Code:
od -cx input.file

Sponsored Links
    #7  
Old 09-04-2010
Registered User
 

Join Date: Mar 2010
Posts: 141
Thanks: 0
Thanked 19 Times in 19 Posts

Code:
sed -n '/^$/!p'


Last edited by Scott; 09-04-2010 at 05:48 AM.. Reason: Code tags
Sponsored Links
Closed Thread

Tags
remove empty lines

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
using vi -c to remove empty lines Habitual Shell Programming and Scripting 3 08-17-2010 10:38 PM
perl or awk remove empty lines when condition jimmy_y Shell Programming and Scripting 2 08-16-2010 08:00 PM
Using sed to remove lines where field is empty figaro Shell Programming and Scripting 4 09-01-2009 03:07 PM
Removing empty lines(space) between two lines containing strings sudhakaryadav Shell Programming and Scripting 3 06-02-2009 10:01 AM
Command/Script to remove duplicate lines from the file? Rahulpict Shell Programming and Scripting 2 02-19-2009 09:13 PM



All times are GMT -4. The time now is 04:08 AM.