
Delete empty lines using sed?
I am trying to delete empty lines using sed:
sed '/^$/d'
but I have no luck with it.
For example, I have these lines:
xxxxxx
yyyyyy
zzzzzz
and I want it to be like:
xxxxxx
yyyyyy
zzzzzz
What should be the code for this?
More
1 Expert Answer

Jeffrey R. answered 10/24/24
Tutor
New to Wyzant
30+ Years of IT Expertise: Networking, Cybersecurity, Client/Serv
Try this to remove empty lines from a file using sed
, you can use the following command creating a new file
sed '/^$/d' filename
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Diamond D.
This command works fine on my end. What's the sed version that you're using (sed --version)? How are you running sed? Are you trying to delete it from a file?10/16/22