Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-04 Thread Warren Block
On Tue, 3 Dec 2002, D J Hawkey Jr wrote:

 In article [EMAIL PROTECTED],
   [EMAIL PROTECTED] writes:
  It's a bit easier if you let Perl do the heavy lifting:
  
  perl -pi -e 's/\r//g' file-to-convert
 
 Even easier (and lighter) if you ditch the perl:
sed -e 's/\r//g' input output

Unfortunately, that doesn't work because BSD sed doesn't understand \r
(it should, IMO, but it doesn't).  It can work if you put an actual CR
in there, and there's the sed-inplace stuff to eliminate the extra file
and redirection, but... see below.
 
 I like the tr(1) conversion too, but I always seem to think in terms of
 sed(1) and awk(1).

I've been making an effort to use Perl for this type of thing, because
it usually saves me time.  When a shell script turns out later to need
strong string processing or any of the other stuff that Perl is good at
but is non-trivial in a shell script, I don't need to rewrite it if it's
already in Perl.  And many scripts that are trivial in Perl (like the
one above) can be non-trivial for csh or sh.

-Warren Block * Rapid City, South Dakota USA


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-04 Thread Jerry McAllister

 ... Much deleted ...

 Ack. Looks like you're right, and I agree with you. If [2addr]l can output
 '\r', [2addr]s/regex/repl/flags ought to understand \r. I have to wonder
 how many times I may have been bitten by this mis-feature.  ;-,
 
 This'll work though:
 sed -e 's/[[:cntrl:]]$//g'
 
   I like the tr(1) conversion too, but I always seem to think in terms of
   sed(1) and awk(1).
 
 And if that sed(1) solution is still too loose, the tr(1) solution reduces
 [[:cntrl:]] to just the CR character.
 

Just to be clear on this issue;  you want to be left with the LF characters
and get rid of the CR characters not the other way around.  I am not a sed
person, but your statement is backwards even if your sed works.

jerry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-04 Thread D J Hawkey Jr
On Dec 04, at 10:20 AM, Jerry McAllister wrote:
 
  This'll work though:
  sed -e 's/[[:cntrl:]]$//g'
  
I like the tr(1) conversion too, but I always seem to think in terms of
sed(1) and awk(1).
  
  And if that sed(1) solution is still too loose, the tr(1) solution reduces
  [[:cntrl:]] to just the CR character.
 
 Just to be clear on this issue;  you want to be left with the LF characters
 and get rid of the CR characters not the other way around.  I am not a sed
 person, but your statement is backwards even if your sed works.

No, I meant what I wrote, though you gave me pause to double-check. The
[[:cntrl:]] and reference to the CR character (\r = carriage-return)
are what's being stripped. I pro'lly should have finished the sentence
with ... for stripping. or somesuch.

 jerry

Dave

-- 
  __ __
  \__   \D. J. HAWKEY JR.   /   __/
 \/\ [EMAIL PROTECTED]/\/
  http://www.visi.com/~hawkeyd/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Thomas von Hassel
Any ideas in re to subject ?

/thomas


--
Thomas von Hassel
DarX @ irc
darxmac @ AIM/iChat
Powered by inkwell...!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Jerry McAllister
 
 S)ubject: Re: tool/method to convert DOS line endings to UNIX line endings
 Any ideas in re to subject ?

First of all, please put all relevant information in the body of your
message.  It makes it very difficult to read and impossible to quote
things that are only mentioned in the subject line.  This is a matter
of practicallity as well as courtesy.

Two possibilities:

Are you coming from a DOS place to a UNIX place or are the files
already in your UNIX place and you need to fix them there?

If you are moving th efiles, use ftp in ASCII mode.  It will then
do the conversion for you.  After you make the ftp connection and
before GETting or PUTting the file, type ASCII to select ASCII mode.

If the file is already on FreeBSD UNIX then use 'tr(1)'.
Presuming your text file is called dosfile and you convert it to
a file named unixfile for example type:

  tr -d \r  dosfile  unixfile

jerry

 
 /thomas
 
 --
 Thomas von Hassel
 DarX @ irc
 darxmac @ AIM/iChat
 Powered by inkwell...!

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Thomas von Hassel

On Tuesday, December 3, 2002, at 10:11 PM, Jerry McAllister wrote:



If you are moving th efiles, use ftp in ASCII mode.  It will then
do the conversion for you.  After you make the ftp connection and
before GETting or PUTting the file, type ASCII to select ASCII mode.


that doesnt work, tried diferent ftp clients both getting and putting 
the files ...

/thomas


--
Thomas von Hassel
DarX @ irc
darxmac @ AIM/iChat
Powered by inkwell...!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message


RE: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Jeff MacDonald
if it's just a few files you can open with 

vi and type this

press escape
:%s/press ctrl-v press ctrl-m//g  
press enter

jeff.
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of Thomas von
 Hassel
 Sent: Tuesday, December 03, 2002 4:47 PM
 Cc: [EMAIL PROTECTED]
 Subject: Re: tool/method to convert DOS line endings to UNIX line
 endings
 
 
 
 On Tuesday, December 3, 2002, at 10:11 PM, Jerry McAllister wrote:
 
 
  If you are moving th efiles, use ftp in ASCII mode.  It will then
  do the conversion for you.  After you make the ftp connection and
  before GETting or PUTting the file, type ASCII to select ASCII mode.
 
 that doesnt work, tried diferent ftp clients both getting and putting 
 the files ...
 
 /thomas
 
 
 --
 Thomas von Hassel
 DarX @ irc
 darxmac @ AIM/iChat
 Powered by inkwell...!
 
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-questions in the body of the message
 

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Lee J Carmichael
If you are going from DOS to Unix you could use the following perl script:

#!/usr/bin/perl -w

use strict;

my $pcfile = shift || /tmp/dosfile.txt ;
my $outfile = shift || /tmp/unixconverted.txt;

die Cannot read $pcfile... unless -r $pcfile;

open(IN, $pcfile) or die Cannot open $pcfile: $!;
open(OUT, $outfile) or die Cannot open $outfile: $!;

$/ = \r; ## pc end of line, damn gates

while(IN) {
   chomp;
   print OUT \n;
}

## should really check the close of these but...
close(IN);
close(OUT);

exit;



Lee Carmichael  
Service Architect - WorkSpace

WAM!NET Inc.
655 Lone Oak Rd Building A
Eagan, MN 55121

ph# 651-256-5292 
email: [EMAIL PROTECTED]

On Tue, 3 Dec 2002, Thomas von Hassel wrote:

 
 On Tuesday, December 3, 2002, at 10:11 PM, Jerry McAllister wrote:
 
 
  If you are moving th efiles, use ftp in ASCII mode.  It will then
  do the conversion for you.  After you make the ftp connection and
  before GETting or PUTting the file, type ASCII to select ASCII mode.
 
 that doesnt work, tried diferent ftp clients both getting and putting 
 the files ...
 
 /thomas
 
 
 --
 Thomas von Hassel
 DarX @ irc
 darxmac @ AIM/iChat
 Powered by inkwell...!
 
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-questions in the body of the message
 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Warren Block
On Tue, 3 Dec 2002, Lee J Carmichael wrote:

 If you are going from DOS to Unix you could use the following perl script:

[script snipped] 

It's a bit easier if you let Perl do the heavy lifting:

perl -pi -e 's/\r//g' file-to-convert

-Warren Block * Rapid City, South Dakota USA



To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Lee J Carmichael
Good point, I pulled it from a script that was doing some additional
magic.

Lee 

On Tue, 3 Dec 2002, Warren Block wrote:

 On Tue, 3 Dec 2002, Lee J Carmichael wrote:
 
  If you are going from DOS to Unix you could use the following perl script:
 
 [script snipped] 
 
 It's a bit easier if you let Perl do the heavy lifting:
 
 perl -pi -e 's/\r//g' file-to-convert
 
 -Warren Block * Rapid City, South Dakota USA
 
 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Larry Rosenman
tr(1), ports/converters/dosunix,ports/converters/unix2dos

LER


--On Tuesday, December 03, 2002 21:59:03 +0100 Thomas von Hassel 
[EMAIL PROTECTED] wrote:

Any ideas in re to subject ?

/thomas


--
Thomas von Hassel
DarX @ irc
darxmac @ AIM/iChat
Powered by inkwell...!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message





--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749




To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Jerry McAllister
 
 On Tuesday, December 3, 2002, at 10:11 PM, Jerry McAllister wrote:
 
 
  If you are moving th efiles, use ftp in ASCII mode.  It will then
  do the conversion for you.  After you make the ftp connection and
  before GETting or PUTting the file, type ASCII to select ASCII mode.
 
 that doesnt work, tried diferent ftp clients both getting and putting 
 the files ...

Gee, I have never found an FTP that didn't work doing that.

Anyway, the 'tr' thing as in my previous message will work.

jerry

 
 /thomas
 
 
 --
 Thomas von Hassel
 DarX @ irc
 darxmac @ AIM/iChat
 Powered by inkwell...!
 

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Thomas von Hassel

On Wednesday, December 4, 2002, at 12:09 AM, Jerry McAllister wrote:



On Tuesday, December 3, 2002, at 10:11 PM, Jerry McAllister wrote:



If you are moving th efiles, use ftp in ASCII mode.  It will then
do the conversion for you.  After you make the ftp connection and
before GETting or PUTting the file, type ASCII to select ASCII mode.


that doesnt work, tried diferent ftp clients both getting and putting
the files ...


Gee, I have never found an FTP that didn't work doing that.

Anyway, the 'tr' thing as in my previous message will work.



yep, like a charm, even wrapped it in some nice shell scripts to make 
thins easier :)

/thomas
--
Thomas von Hassel
DarX @ irc
darxmac @ AIM/iChat
Powered by inkwell...!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message


Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread Kirk Strauser

At 2002-12-03T21:53:29Z, Lee J Carmichael [EMAIL PROTECTED] writes:

 while(IN) {
chomp;
print OUT \n;
 }

Wouldn't that print only an EOL?  Shouldn't that be:

  print OUT $_\n;

or similar?
-- 
Kirk Strauser
In Googlis non est, ergo non est.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: tool/method to convert DOS line endings to UNIX line endings

2002-12-03 Thread D J Hawkey Jr
[Posted and mailed]

In article [EMAIL PROTECTED],
[EMAIL PROTECTED] writes:
 On Tue, 3 Dec 2002, Lee J Carmichael wrote:
 
 If you are going from DOS to Unix you could use the following perl script:
 
 [script snipped] 
 
 It's a bit easier if you let Perl do the heavy lifting:
 
 perl -pi -e 's/\r//g' file-to-convert

Even easier (and lighter) if you ditch the perl:
   sed -e 's/\r//g' input output

I like the tr(1) conversion too, but I always seem to think in terms of
sed(1) and awk(1).

 -Warren Block * Rapid City, South Dakota USA

:-)
Dave

-- 

Windows: Where do you want to go today?
Linux: Where do you want to go tomorrow?
FreeBSD: Are you guys coming, or what?


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message