Sunday 1 April 2018

windows - How to remove blank lines in .txt files


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




Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...