If you have a text file that contains a lot a lot of blank lines, you may want to avoid them printing in the screen when you try to read that file, there is a simple way to do that using either less or cat I have create a file to show you how this works.

cat -n text-file.txt

This is the output with all the blank lines

     1  Hello
     2
     3  This is a text file
     4  with
     5
     6  a lot
     7
     8
     9
    10
    11  of blank lines
    12
    13
    14  that I will use to 
    15
    16
    17
    18
    19  show the uses of -s switch
    20
    21  of the
    22
    23
    24
    25
    26  less command
    27

I have used -n to print the line numbers as you can see there are 27 lines there but a lot of them are contiguous blank lines, now lets see the output with the -s swith on.

cat -s -n text-file.txt

     1  Hello
     2
     3  This is a text file
     4  with
     5
     6  a lot
     7
     8  of blank lines
     9
    10  that I will use to 
    11
    12  show the uses of -s switch
    13
    14  of the
    15
    16  less command
    17

Now there are only 17 lines printed, the file has not changed only the output of cat on the screen, contiguous blank lines were converted into only one blank line.

You can also create a new file, redirecting the output to another file

cat -s text-file.txt > new-text-file.txt

-s switch also works on less