public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: How do I remove CR/LF from text file
       [not found] <EC421C2230BBD211A11400805FA7784D25DCE2@express8.res.utc.com>
@ 2001-02-02 10:36 ` Brian Keener
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Keener @ 2001-02-02 10:36 UTC (permalink / raw)
  To: cygwin

Mark B.           UTRC Stucky wrote:
> cat $fil | tr -d '\r' > pc2u.tmpfile

This is going from dos to unix isn't it - not Unix to dos.




--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-05  8:14 ` Malcolm Boekhoff
@ 2001-02-05  9:36   ` Brian Keener
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Keener @ 2001-02-05  9:36 UTC (permalink / raw)
  To: Cygwin News Group

Malcolm Boekhoff wrote:
> file in Word (and probably Wordpad)
> and then save it as text. This will put the \r\n sequence back in. 

Actually, it doesn't appear to - they just seem to display it properly and then saves it the same 
way and it still looks bad in Notepad and my email program.

> You can also use vim (part of Cygwin) to read the file in, change
> the file type to "dos" (via ":set fileformat=dos") then save it.

Hadn't tried this yet (actually didn't know about it) but just did and that works like a champ - I 
can live with that solution.  Thanks for the new command in vim.

Brian



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-02  8:50 Brian Keener
  2001-02-02  9:11 ` Larry Hall
  2001-02-02  9:45 ` Charles S. Wilson
@ 2001-02-05  8:14 ` Malcolm Boekhoff
  2001-02-05  9:36   ` Brian Keener
  2 siblings, 1 reply; 9+ messages in thread
From: Malcolm Boekhoff @ 2001-02-05  8:14 UTC (permalink / raw)
  To: Cygwin News Group

DOS2UNIX
--------
You can strip out the carriage-return from carriage-return+line-feed with "tr" (i.e. DOS to Unix):

    tr -d \r <inputFile >outputFile

The "-d" means "delete".

UNIX2DOS
--------
However, I think you want to put the carriage-return in and I don't know how to do this. If you look at a Unix file (one with lines
separated by \n and not \r\n) in Notepad, you just see one great big line. You can look at the file in Word (and probably Wordpad)
and then save it as text. This will put the \r\n sequence back in. You can also use vim (part of Cygwin) to read the file in, change
the file type to "dos" (via ":set fileformat=dos") then save it.

----- Original Message -----
From: "Brian Keener" <bkeener@thesoftwaresource.com>
To: "cygwin" <cygwin@sourceware.cygnus.com>
Sent: Friday, February 02, 2001 4:49 PM
Subject: How do I remove CR/LF from text file


> I was working on some code and output a text file which displays fine in
> cygwin but I wanted to email the text to someone from within windows and
> if I look at the text in wordpad it looks fine but if I look at it in
> notepad then it is screwy and in either case if I try to cut and paste
> into my email program then the text is still real screwy and I don't want
> to have to edit it.  I assume this is a CR/LF issue - not a bug - I just
> can't figure out how to change it.
>
> The text was originally created by sending to /tmp/foo which is on /
> which is a binary mount and so I did a
>
> cat /tmp/foo > /windows/temp/foo
>
> in which case /windows is a text mount thinking this would fix it, but it
> does not.  If I however go back and recreate the text file by outputting
> it to /windows/temp/foo in the first place - then wordpad, notepad and my
> email on like it, again I am assuming this is CR/LF related but that is
> an assumption.
>
> Can someone provide me with a line that allows me to do a conversion
> after the fact like this or is there such a beast - On some unixen we had
> dos2unix and such.
>
> Thanks for any input.
>
>
>
> --
> Want to unsubscribe from this list?
> Check out: http://cygwin.com/ml/#unsubscribe-simple



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-02 10:11 Bernard Dautrevaux
@ 2001-02-02 10:36 ` Brian Keener
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Keener @ 2001-02-02 10:36 UTC (permalink / raw)
  To: cygwin

Bernard Dautrevaux wrote:
> Can't you directly generate your file as DOS text? either by writing on a
> text-mount,
That was how I finally got what I wanted - but since needing it that way was 
an afterthought and not normal operation - then I don't want it that way 
permanently but only would like to know how to convert if I need to again.

> As you decribe the problem (wordpad understand the file but notepad displays
> black rectangles instead of the EOL I think), you need not convert to UNIX
> from DOS but the other way round: native Windows programs need CF/LF

This would be true - I thought that was what I explained but I may have left 
something out - so sorry.




--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: How do I remove CR/LF from text file
@ 2001-02-02 10:11 Bernard Dautrevaux
  2001-02-02 10:36 ` Brian Keener
  0 siblings, 1 reply; 9+ messages in thread
From: Bernard Dautrevaux @ 2001-02-02 10:11 UTC (permalink / raw)
  To: 'bkeener@thesoftwaresource.com', cygwin

> -----Original Message-----
> From: Brian Keener [ mailto:bkeener@thesoftwaresource.com ]
> Sent: Friday, February 02, 2001 7:03 PM
> To: cygwin
> Subject: Re: How do I remove CR/LF from text file
> 
> 
> Larry Hall wrote:
> > How about piping it through tr, mapping \n to \r\n?
> >
> I can't seem to get tr to exchange more than one character since I am 
> only starting with one character.
> 
>  tr "[\n]" "[\n\r]" < /tmp/foo >/windows/temp/foo2     no 
> apparent change
> 
>  tr "[\n]" "[\r]" < /tmp/foo >/windows/temp/foo2  No apparent 
> change when 
> looking in Notepad
> 
>  tr "[\n]" "[~]" < /tmp/foo >/windows/temp/foo2  all then newlines 
> changed to ~
> 
> Got any idea what I am doing wrong - I don't see any other flags or 
> switches that might make a difference.

Can't you directly generate your file as DOS text? either by writing on a
text-mount, or by explicitely writing to a file opened in text mode, by
open("...", O_WRONLY|O_TEXT) or fopen("...", "wt");

As you decribe the problem (wordpad understand the file but notepad displays
black rectangles instead of the EOL I think), you need not convert to UNIX
from DOS but the other way round: native Windows programs need CF/LF line
terminations -- at least old buggy ones like bug^H^H^Hnotepad :-)

HTH

	Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux@microprocess.com
		b.dautrevaux@usa.net
-------------------------------------------- 

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-02  9:11 ` Larry Hall
@ 2001-02-02 10:03   ` Brian Keener
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Keener @ 2001-02-02 10:03 UTC (permalink / raw)
  To: cygwin

Larry Hall wrote:
> How about piping it through tr, mapping \n to \r\n?
>
I can't seem to get tr to exchange more than one character since I am 
only starting with one character.

 tr "[\n]" "[\n\r]" < /tmp/foo >/windows/temp/foo2     no apparent change

 tr "[\n]" "[\r]" < /tmp/foo >/windows/temp/foo2  No apparent change when 
looking in Notepad

 tr "[\n]" "[~]" < /tmp/foo >/windows/temp/foo2  all then newlines 
changed to ~

Got any idea what I am doing wrong - I don't see any other flags or 
switches that might make a difference.



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-02  8:50 Brian Keener
  2001-02-02  9:11 ` Larry Hall
@ 2001-02-02  9:45 ` Charles S. Wilson
  2001-02-05  8:14 ` Malcolm Boekhoff
  2 siblings, 0 replies; 9+ messages in thread
From: Charles S. Wilson @ 2001-02-02  9:45 UTC (permalink / raw)
  To: bkeener; +Cc: cygwin

Try the d2u program at
http://www.neuro.gatech.edu/users/cwilson/cygutils/V1.1/misc/

--Chuck


Brian Keener wrote:
> 
> I was working on some code and output a text file which displays fine in
> cygwin but I wanted to email the text to someone from within windows and
> if I look at the text in wordpad it looks fine but if I look at it in
> notepad then it is screwy and in either case if I try to cut and paste
> into my email program then the text is still real screwy and I don't want
> to have to edit it.  I assume this is a CR/LF issue - not a bug - I just
> can't figure out how to change it.
> 
> The text was originally created by sending to /tmp/foo which is on /
> which is a binary mount and so I did a
> 
> cat /tmp/foo > /windows/temp/foo
> 
> in which case /windows is a text mount thinking this would fix it, but it
> does not.  If I however go back and recreate the text file by outputting
> it to /windows/temp/foo in the first place - then wordpad, notepad and my
> email on like it, again I am assuming this is CR/LF related but that is
> an assumption.
> 
> Can someone provide me with a line that allows me to do a conversion
> after the fact like this or is there such a beast - On some unixen we had
> dos2unix and such.
> 
> Thanks for any input.
> 
> --
> Want to unsubscribe from this list?
> Check out: http://cygwin.com/ml/#unsubscribe-simple

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How do I remove CR/LF from text file
  2001-02-02  8:50 Brian Keener
@ 2001-02-02  9:11 ` Larry Hall
  2001-02-02 10:03   ` Brian Keener
  2001-02-02  9:45 ` Charles S. Wilson
  2001-02-05  8:14 ` Malcolm Boekhoff
  2 siblings, 1 reply; 9+ messages in thread
From: Larry Hall @ 2001-02-02  9:11 UTC (permalink / raw)
  To: bkeener, cygwin

At 11:49 AM 2/2/2001, Brian Keener wrote:
>I was working on some code and output a text file which displays fine in 
>cygwin but I wanted to email the text to someone from within windows and 
>if I look at the text in wordpad it looks fine but if I look at it in 
>notepad then it is screwy and in either case if I try to cut and paste 
>into my email program then the text is still real screwy and I don't want 
>to have to edit it.  I assume this is a CR/LF issue - not a bug - I just 
>can't figure out how to change it.
>
>The text was originally created by sending to /tmp/foo which is on / 
>which is a binary mount and so I did a 
>
>cat /tmp/foo > /windows/temp/foo 
>
>in which case /windows is a text mount thinking this would fix it, but it 
>does not.  If I however go back and recreate the text file by outputting 
>it to /windows/temp/foo in the first place - then wordpad, notepad and my 
>email on like it, again I am assuming this is CR/LF related but that is 
>an assumption.
>
>Can someone provide me with a line that allows me to do a conversion 
>after the fact like this or is there such a beast - On some unixen we had 
>dos2unix and such.



How about piping it through tr, mapping \n to \r\n?



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

* How do I remove CR/LF from text file
@ 2001-02-02  8:50 Brian Keener
  2001-02-02  9:11 ` Larry Hall
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Brian Keener @ 2001-02-02  8:50 UTC (permalink / raw)
  To: cygwin

I was working on some code and output a text file which displays fine in 
cygwin but I wanted to email the text to someone from within windows and 
if I look at the text in wordpad it looks fine but if I look at it in 
notepad then it is screwy and in either case if I try to cut and paste 
into my email program then the text is still real screwy and I don't want 
to have to edit it.  I assume this is a CR/LF issue - not a bug - I just 
can't figure out how to change it.

The text was originally created by sending to /tmp/foo which is on / 
which is a binary mount and so I did a 

cat /tmp/foo > /windows/temp/foo 

in which case /windows is a text mount thinking this would fix it, but it 
does not.  If I however go back and recreate the text file by outputting 
it to /windows/temp/foo in the first place - then wordpad, notepad and my 
email on like it, again I am assuming this is CR/LF related but that is 
an assumption.

Can someone provide me with a line that allows me to do a conversion 
after the fact like this or is there such a beast - On some unixen we had 
dos2unix and such.

Thanks for any input.



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-02-05  9:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <EC421C2230BBD211A11400805FA7784D25DCE2@express8.res.utc.com>
2001-02-02 10:36 ` How do I remove CR/LF from text file Brian Keener
2001-02-02 10:11 Bernard Dautrevaux
2001-02-02 10:36 ` Brian Keener
  -- strict thread matches above, loose matches on Subject: below --
2001-02-02  8:50 Brian Keener
2001-02-02  9:11 ` Larry Hall
2001-02-02 10:03   ` Brian Keener
2001-02-02  9:45 ` Charles S. Wilson
2001-02-05  8:14 ` Malcolm Boekhoff
2001-02-05  9:36   ` Brian Keener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).