Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the command to delete empty lines in a file using sed?

  • What is the sed command to delete empty lines in a file.
  • What is the command (sed command?) to delete empty files in a folder?
like image 809
Ranjith Siji Avatar asked Dec 07 '22 14:12

Ranjith Siji


1 Answers

You have to 'd' which is used to delete.

Ex:

 sed -i '/^$/d' test

-i - is used to affect the file.

^ - is a beginning of line

$ - is a end of line

d - delete if there is a empty line

I hope this will help you.

like image 182
sat Avatar answered Dec 11 '22 11:12

sat