Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to change a text file's format, removing all blank lines. How can I do that?


(2) 5. The function of the condenser is to:

a) vapourise the liquid refrigerant

b) change high pressure refrigerant vapour to liquid

c) pressurise low pressure refrigerant vapour

d) vent off vapourised refrigerant

e) lower the liquid refrigerant pressure

(2) 6. One tonne of refrigeration is:

a) 13958 kJ per day

b) 100 kJ per minute

c) 233 kJ per minute

d) 13958 J per hour

e) 335 J per second


(2) 5. The function of the condenser is to:
a) vapourise the liquid refrigerant
b) change high pressure refrigerant vapour to liquid
c) pressurise low pressure refrigerant vapour
d) vent off vapourised refrigerant
e) lower the liquid refrigerant pressure

(2) 6. One tonne of refrigeration is:
a) 13958 kJ per day
b) 100 kJ per minute
c) 233 kJ per minute
d) 13958 J per hour
e) 335 J per second

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You can use GNU sed:

sed -i -e "/^$/d" su.txt

Will delete blank lines.


If you're on a BSD variant or OS X, use this instead:

sed -i '' -e "/^$/d" su.txt

Here, -i takes an extension as an argument – using the GNU sed syntax would result in a file su.txt-e being created.

share|improve this answer
    
Hello ,thanks for help,. I installed GNU sed in Window vista , tried SED itself not working, no SED window up –  Brant Jun 24 '12 at 16:22
    
@Brant What do you mean by "not working" and "no SED window up"? Can you run the command from a prompt? If not, what errors do you see? –  slhck Jun 24 '12 at 16:31
    
First I could not find SED shortcut anywhere on startup menu or desktop. Then I run the bin in Program Files--> GnuWin32-->bin-->SED under C drive. Then Black window up for a split of second and dissappeared –  Brant Jun 24 '12 at 16:43
    
@Brant it's a command line tool. That command will edit it in-place, invoked from a shell. There is no GUI. I recommend you install cygwin on Windows and use the one that comes with it. –  Keith Jun 24 '12 at 18:20
    
Installing cygwin just to remove some lines from a text file seems a bit overkill to me. –  Richard Jun 24 '12 at 19:56
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.