 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Remove Empty Lines from a File on ubuntu
Do you know how to remove empty lines from the file in Ubuntu? It may also be performed manually if the file has few strains but if the file has hundreds of thousands of line that is tough to be accomplished manually. This article explains you about – how to remove empty lines from a file on Ubuntu.
Our sample file should be like this –

Use the following command to remove the Empty lines from a file as shown below –
$ ex -s +'v/\S/d' -cwq abc.txt
In the above command abc.txt indicates the file name. The sample output should be like this –

To create a new file without empty lines from the previous file, use the following command –
$ awk 'NF > 0' abc.txt > bbc.txt
In the above command, it creates a file called bbc.txt and copies the whole content from abc.txt without empty lines. To verify the file, use the following command –
$ nano bbc.txt
The sample output should be like this –

In the above file, it has deleted empty lines and created the result in another file called bbc.txt in the same directory.
In the above article, we have learnt – Learn how to Remove Empty Lines from a File on ubuntu. In our next articles, we will come up with more Linux based tricks and tips. Keep reading!
