If you insist to perform it inside geany
editor - You can use geany lineoperations plugin which add the Remove Empty Lines feature to geany
A simpler way might be - to treat the file as a regular text file, and remove the empty lines using command-line
tools (e.g. sed
)
Here You can see several examples how to remove empty line from a text file.
Using sed
:
sed '/^$/d' <input-file>
To delete all empty lines from a file called /tmp/data.txt, enter:
sed '/^$/d' /tmp/data.txt
To store output to another file use redirection operator:
sed '/^$/d' /tmp/data.txt > /tmp/output.txt
Note: Using sed
to remove empty lines shouldn't change anything with the non-empty lines in file
Note: In order to modify the file in place you should use sed
-i
flag:
sed -i '/^$/d' <input-file>
Example:
The original text file:
$ cat in.txt
This is a test
Linux rulez
Windows sucks
Ubuntu is good server disro
sed
output when running on the file:
$ sed '/^$/d' in.txt
This is a test
Linux rulez
Windows sucks
Ubuntu is good server disro
<carriage return><line feed>
characters at the end of each line, not only<line feed>
as in linux text files. – sudodus Jan 24 '18 at 15:55dos2unix
to convert from a DOS formatted text file. Install withsudo apt install dos2unix
from the repository 'universe'. – sudodus Jan 24 '18 at 17:55