Two Ways to Remove Blank Lines from a File in Bash

Removing blank lines from a file is very simple in bash. Here are two ways in which this can be accomplished using “sed” and “grep”

sed -i '/^$/d' filename


grep -v '^$' inputfile > outputfile
Share This!

Add a Comment

Your email address will not be published.

Sign up for our Newsletter

Download "Google Search Pro"

Enter your email and stay on top of things,