Home Forums Unix & Linux How to delete empty lines and lines only with white spaces from a file

Tagged: ,

  • Author
    Posts
  • admin
    Keymaster
    Post count: 111

    Below command helps me to remove only blank or empty lines from a file. Bit it not removes a line with white space.

    sed '/^$/d' filename > filename.temp
  • Anonymous
    Post count: 1

    Try:

    sed '/^ *$/d' filename > filename.tmp
    filename.tmp > filename

    This will remove blank lines and lines with only white spaces from a file.

Reply To: How to delete empty lines and lines only with white spaces from a file
Your information: