Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Linux – delete lines with ":\n"

I’m looking for a command to delete lines where ":\n" is found. For example from:

test1:
test2:true
tool3:
tool4:false

to:

test2:true
tool4:false

I’m not used to sed very much I tried:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

sed '/:\r\n/d' doesn’t work

sed '/test1/d' works for this line

>Solution :

Instead of trying to match the newline character, you could match the EOL character, represented by $:

sed '/:$/d' file.txt
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading