Web Server forum
Back To The Forum Home!Search!Private Messaging System

This is Interesting: Free IT Magazines Now Free shipping to   
Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix questions > How can I erase these blank lines




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    How can I erase these blank lines  
Han JIANG


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-30-04 05:35 PM

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.

Thanks!







[ Post a follow-up to this message ]



    Re: How can I erase these blank lines  
Charles Demas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-30-04 06:41 PM

In article <c4c9s5$667$1@unlnews.unl.edu>,
Han JIANG <jianghanunl@yahoo.com> 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.

awk 'NF>0' infile > outfile

or more cryptically:

awk 'NF' infile > outfile

Chuck Demas

--
Eat Healthy        |   _ _   | Nothing would be done at all,
Stay Fit           |   @ @   | If a man waited to do it so well,
Die Anyway         |    v    | That no one could find fault with it.
demas@theworld.com |  \___/  | http://world.std.com/~cpd





[ Post a follow-up to this message ]



    Re: How can I erase these blank lines  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-30-04 06:41 PM

On Tue, 30 Mar 2004 at 17:16 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.

grep -v '^$' FILE >NEWFILE

Or:

grep '.' FILE >NEWFILE

Or:

awk '/./'  FILE >NEWFILE

etc......

--
Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
 ========================================
===========================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License





[ Post a follow-up to this message ]



bravored is offline     Re: Re: How can I erase these blank lines  
bravored


View Ip Address Report This Message To A Moderator Edit/Delete Message


Click Here to See the Profile for bravored Click here to Send bravored a Private Message Find more posts by bravored Add bravored to your buddy list
 
03-31-04 09:17 AM

Hi NewBe Here too

Couldnt you just do dd?

Thanks

quote:
Originally posted by Chris F.A. Johnson On Tue, 30 Mar 2004 at 17:16 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. grep -v '^$' FILE >NEWFILE Or: grep '.' FILE >NEWFILE Or: awk '/./' FILE >NEWFILE etc...... -- Chris F.A. Johnson http://cfaj.freeshell.org/shell ======================================== =========================== My code (if any) in this post is copyright 2004, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License




[ Post a follow-up to this message ]



    Re: How can I erase these blank lines  
phn@icke-reklam.ipsec.nu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-31-04 05:40 PM

In comp.unix.misc Han JIANG <jianghanunl@yahoo.com> 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.

Your "pc" ( running wintendo i assume ?) will use two characters
^M ( return ) and ^J ( line feed ) between lines. Un*x uses only ^J
but will sometimes present  ^M as another line feed ( controlled by
the command "stty".



> 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.

Edit the file :-)

It's not so difficult, several tools are available

vi, tr dos2ascii etc..

Using "vi" :

> vi file
( file is opend, press ':' ( cursor will go to bottom line), type
1,$s/^V^M//g  ( press return. ^V is made by holding control key while
pressing 'V', ^M is made by holding control while pressing 'M')


For a good introduction get "Essential System Administration" by eileen fris
h,
it contains lots of examples and is a good primer for unix knowledge.

> Thanks!



--
Peter Håkanson
IPSec  Sverige      ( At Gothenburg Riverside )
Sorry about my e-mail address, but i'm trying to keep spam out,
remove "icke-reklam" if you feel for mailing me. Thanx.





[ Post a follow-up to this message ]



    Re: How can I erase these blank lines  
Mark Daniels


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-01-04 06:39 PM

"Han JIANG" <jianghanunl@yahoo.com> wrote in message news:<c4c9s5$667$1@unlnews.unl.edu>...

> 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.
>
> Thanks!

If you are running Solaris you can try running 'dos2unix'.

Mark





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:04 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 

Back To The Top
Home | Usercp | Faq | Register