G
G
Groofy2015-08-12 10:49:03
JavaScript
Groofy, 2015-08-12 10:49:03

How to remove blank lines from a text file?

Given

Text file with many lines
There are lines with text and empty lines
Empty lines contain tabs (tab) (\t)
Lines with text also contain tabs

Question
How to delete lines with tabs (or without them) in which there is no text

Answer the question

In order to leave comments, you need to log in

4 answer(s)
W
wagoodoogoo, 2019-02-01
@wagoodooogoo

it is not clear where this code comes from, but the submit_url variable is written in the code, but it is not clear where it is applied

A
Alexey Ukolov, 2015-08-12
@alexey-m-ukolov

\n\t+\n
Here is a regular expression that will find empty strings.
What to do next with them is up to you, your task is not clear from the tags.

A
Andrey Burov, 2015-08-12
@BuriK666

sed '/^\s*$/d' -i filename

A
Alexey Ostin, 2015-08-12
@nitso

If the question is about programming, then it should be solved accordingly.
And for everyday use:
findstr /v "^\s?[\r\n]+$" file.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question