Two Ways to Remove Blank Lines from a File in Bash February 26, 2014 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' filenamesed -i '/^$/d' filename and grep -v '^$' inputfile > outputfilegrep -v '^$' inputfile > outputfile Share This! Related posts: Remove White Spaces from Filesnames in Bash File Input Validation. MP3 to MP3 Player Uploader in Bash 10 Useful Find Command for Linux Users Tags:blank, grep, lines, removing, sed Related Posts A Comprehensive Guide to TCP/IP Configuration in Linux. How to Mount an NTFS Partition in Linux During Boot How to Recover Deleted Files with Photorec About The Author miatech Add a Comment Cancel reply Your email address will not be published.Comment Save my name, email, and website in this browser for the next time I comment.