top of page
Writer's pictureJatin Madaan

Sed Command to remove blank lines from a file in Unix .

Let's say we have a file - date.txt which has 5 lines in total out of which 2 lines are blank .


We now need to remove blank lines so that space can be saved on disk (for very large files ) or for some other reasons.


This can easily be done using Sed command :


sed '/^$/d' date.txt


Here ^$ - means blank line , so search for blank lines and delete using d command of vi editor.



This is a very simple yet useful command.



12 views0 comments

Comments


bottom of page