Re: How to erase these additional blank lines?

From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 03/30/04


Date: Tue, 30 Mar 2004 17:46:17 GMT

Han JIANG wrote:

> Hi,
> I am a newbie on unix. I met a strange problem here on Origin 2000.
>
> I created a text data file which had 1,000 lines on my pc (Windows of
> course) and upload it to my acoount on Origin.When I use vi to edit it on
> Origin, I found there is a additional blank line between every 2 lines!
> That makes my program cann't input this datafile.
>
> Who know what happen here? And how can erase these additional blank lines?
> Please don't say erase them line by line since I have 1000 lines there.

On unix:

grep -v ^$ oldfile > newfile

will remove zero length lines. If they might have space or tabs
in them:

grep -v '^[[:space:]]*$' oldfile > newfile

-- glen



Relevant Pages

  • Re: How can I erase these blank lines
    ... > I am a newbie on unix. ... I met a strange problem here on Origin 2000. ... > course) and upload it to my acoount on Origin.When I use vi to edit it on ... > Please don't say erase them line by line since I have 1000 lines there. ...
    (comp.unix.programmer)
  • Re: How to erase these additional blank lines?
    ... > I am a newbie on unix. ... I met a strange problem here on Origin 2000. ... > course) and upload it to my acoount on Origin.When I use vi to edit it on ... > Please don't say erase them line by line since I have 1000 lines there. ...
    (comp.lang.fortran)
  • Re: How can I erase these blank lines
    ... > course) and upload it to my acoount on Origin.When I use vi to edit it on ... > Please don't say erase them line by line since I have 1000 lines there. ... If you are running Solaris you can try running 'dos2unix'. ...
    (comp.unix.questions)
  • Re: How can I erase these blank lines
    ... > course) and upload it to my acoount on Origin.When I use vi to edit it on ... > Please don't say erase them line by line since I have 1000 lines there. ... If you are running Solaris you can try running 'dos2unix'. ...
    (comp.unix.misc)
  • Re: Question on Perl printing
    ... I edited a file in windows and uploaded it into unix. ... > Upload as ASCII or use fromdos ... Many live that deserve death. ...
    (comp.lang.perl.misc)