Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After converting file using **unix2dos** command it is having some empty lines. Please help me. How to handle this?

I tried to delete empty lines as follow, but couldn't work.

$ sed '/^$/d' /tmp/data.txt

Hey following examples also didn't work. Pl help

This is source data before using unix2dos.


1 BALA 09/23/2013

2 KRISHH 09/24/2013

3 billy 09/24/2013

After using unix2dos it is coming as


1 BALA 09/23/2013

2 KRISHH 09/24/2013

3 billy 09/24/2013

first and second record there is an empty line coming up..may be in bewteen data also


share|improve this question

migrated from Oct 20 '13 at 13:50

This question came from our site for professional and enthusiast programmers.

Does sed '/^\s*$/d' work ? – cnicutar Sep 26 '13 at 10:15

Under Unix newlines are "\n" and under window they are "\r\n" to convert them you need to replace "\r\n" with "\n", or just get rid of all "\r" if you use notepad++ it can do the conversion for you, and also anything with find and replace should work.

\n = new line

\r = carriage return

Google "Unix line endings" for more information.

share|improve this answer

As you've mentioned your file has CR-LF line endings. As such, sed '/^$/d wouldn't work.


sed '/^\x0D$/d' inputfile
share|improve this answer
hey...sorry it didn't work... – user2814717 Sep 26 '13 at 10:22
Try sed '/^\s*$/d' as commented – devnull Sep 26 '13 at 10:25
sorry..this one also didn't work..why unix2dos command is ging empty lines – user2814717 Sep 26 '13 at 10:31
@user2814717 Post some lines of input before and after issuing unix2dos. Update your question with the information. – devnull Sep 26 '13 at 11:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.