a final ^M 
Author Message
 a final ^M

Dear netters, i have a file that looks like (was copied from
MSDOS):

...^M
....^M
....^M

and i want get rid of these ^M at the end of each line.
How can i do this with awk? or sed or whatever is easer?

Thanks in advance,
                  Jorge Luis



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:

> Dear netters, i have a file that looks like (was copied from
> MSDOS):

> ...^M
> ....^M
> ....^M

> and i want get rid of these ^M at the end of each line.
> How can i do this with awk? or sed or whatever is easer?

> Thanks in advance,
>                   Jorge Luis

Well, why not a tr command ?

sort of : tr -d "\r" < dosfile > cleansedfile

--
"Certains me nomment '^R[a-z\'-]+$', mais j'ai tant d'autres noms ...".



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:


>> Dear netters, i have a file that looks like (was copied from
>> MSDOS):

>> ...^M
>> ....^M
>> ....^M

>> and i want get rid of these ^M at the end of each line.
>> How can i do this with awk? or sed or whatever is easer?

>> Thanks in advance,
>>                   Jorge Luis

>Well, why not a tr command ?

>sort of : tr -d "\r" < dosfile > cleansedfile

I'm not sure that the "\r" will work, but this should:

tr -d '\015' < dosfile > cleansedfile

man tr

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:


> > Dear netters, i have a file that looks like (was copied from
> > MSDOS):

> > ...^M
> > ....^M
> > ....^M

> > and i want get rid of these ^M at the end of each line.
> > How can i do this with awk? or sed or whatever is easer?

> > Thanks in advance,
> >                   Jorge Luis

> Well, why not a tr command ?

> sort of : tr -d "\r" < dosfile > cleansedfile

Thank you, it did the work

                         Best Regards



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:




> >> Dear netters, i have a file that looks like (was copied from
> >> MSDOS):

> >> ...^M
> >> ....^M
> >> ....^M

> >> and i want get rid of these ^M at the end of each line.
> >> How can i do this with awk? or sed or whatever is easer?

> >> Thanks in advance,
> >>                   Jorge Luis

> >Well, why not a tr command ?

> >sort of : tr -d "\r" < dosfile > cleansedfile

> I'm not sure that the "\r" will work, but this should:

> tr -d '\015' < dosfile > cleansedfile

Thank to you Charles, it did what i was looking for.

 $tr -d "\r" < dosfile > cleansedfile

produced the same result.

                       Best regards
                                   Jorge



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M


Quote:
>Dear netters, i have a file that looks like (was copied from MSDOS):

>...^M
>....^M
>....^M

>and i want get rid of these ^M at the end of each line.
>How can i do this with awk? or sed or whatever is easer?

awk can be complex  not all ?awk's behave nicely with ^M's

sed 's/.$//' input > output
  will do it nicely

As others have pointed out 'tr' will do it, but tr is not awk or sed ;-)
Mark
---
Mark Katz
Mark-it, London. Delivering MR-IT/Internet solutions
Tel: (44) 20-8731 7516, Fax: (44) 20-8458 9554
For latest information about ISPC/ITE - see http://www.e-tabs.com



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M


Quote:

> Dear netters, i have a file that looks like (was copied from
> MSDOS):

> ...^M
> ....^M
> ....^M

> and i want get rid of these ^M at the end of each line.
> How can i do this with awk? or sed or whatever is easer?

Why not use dos2ux <input-file >output-file command?  The ^M are
indicative of a dos file that was copied/ftp'd to a unix box.

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

...

Quote:

>As others have pointed out 'tr' will do it, but tr is not awk or sed ;-)

sed is OT for this NG.

Of course, the real answer to the question is: Use ascii mode in FTP.
(But this is not comp.unix.shell, either)



Sun, 29 Dec 2002 03:00:00 GMT  
 a final ^M

...

Quote:
>sed is OT for this NG.

>Of course, the real answer to the question is: Use ascii mode in FTP.
>(But this is not comp.unix.shell, either)

So offer an awk script!

awk '{ sub("\r$", ""); print }' dosfile > unixfile

But as Kenny implies, awk or sed may not be the ideal tools.

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 30 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:

> Why not use dos2ux <input-file >output-file command?

Because "dos2ux" is not available on most machines (in fact, I don't
know any machine where it is). Probably it's a script provided by
someone just on your machine.

It's the same for d2u, dtou, dos2unix: none of them is standard.

Regards...
                Michael



Tue, 31 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:


>> Why not use dos2ux <input-file >output-file command?

>Because "dos2ux" is not available on most machines (in fact, I don't
>know any machine where it is). Probably it's a script provided by
>someone just on your machine.

>It's the same for d2u, dtou, dos2unix: none of them is standard.

Indeed.  dos2ux is, I think, a HP/UX (or maybe AIX) thing.
And, under Solaris, dos2unix doesn't do what you think it does.  Instead, it
has to do with converting the high ASCII (DOS line drawing characters) to
something Unix-ish.  In any case, the (Solaris) man page for dos2unix is
very confusing.

I posted the following script to some shell group recently; I find it
quite useful; I use it on all my Unix systems.  It should be linked as
~/bin/{dosORunix,unix2dos,dos2unix}.  Don't bother critiquing it - it works
well enough as is.

#!/bin/sh
# This version should be linked as unix2dos, dos2unix, and dosORunix
fn=`basename $0`
[ "$fn" = "dosORunix" ] && {
        gawk 'FNR == 1 { print FILENAME,"appears to be in",

        exit 0
        }
tmp=tmptmp.$$
trap "rm -f $tmp" 0 1 2 3 15
action=DOS
[ "$fn" = "dos2unix" ] && action=Unix
for i
    do
        echo "${action}-ifying file: $i"
        mv $i $tmp
        if [ $action = DOS ]
        then    gawk 'BEGIN {ORS = "\r\n"};1' $tmp > $i
        else    tr -d '\r' < $tmp > $i
        fi
    done



Tue, 31 Dec 2002 03:00:00 GMT  
 a final ^M

Quote:

>> Why not use dos2ux <input-file >output-file command?

>Because "dos2ux" is not available on most machines (in fact, I don't
>know any machine where it is). Probably it's a script provided by
>someone just on your machine.

dos2unix is a standard tool in the Solaris Operating System.

Quote:

>It's the same for d2u, dtou, dos2unix: none of them is standard.

>Regards...
>            Michael

---
Regards

Michael.



Tue, 31 Dec 2002 03:00:00 GMT  
 a final ^M


Quote:


>>> Why not use dos2ux <input-file >output-file command?

>>Because "dos2ux" is not available on most machines (in fact, I don't
>>know any machine where it is). Probably it's a script provided by
>>someone just on your machine.

>dos2unix is a standard tool in the Solaris Operating System.

1) It (under Solaris) doesn't do what you expect it to (see my other post)
2) It isn't standard Unix - which is really the point.


Tue, 31 Dec 2002 03:00:00 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. One final, final thought

2. Final Final beta of Win32 Extensions available!

3. DDE Command reference for MS Office / MS Word

4. MS OUTLOOK, MS PROJECT replication.

5. MS SQL 7.0 vs. MS SQL 2000

6. Class(y) 2.4b, with documentation for MS-Word 97, MS-Word 6.0 and WordPerfect 7.0

7. How to use MS TreeView and MS ImageList

8. Haskell and MS-Excel, MS-Access

9. REXX for MS Windows 3.1 or MS WfWG 3.11

10. RexxGMSQ just released---IBM Object Rexx---MS SQL Server APIs for MS Windows NT

11. MS-COBOL 4.50 MS-Windows progs

12. MS Fortran DLL called from MS VB 6.0 problem

 

 
Powered by phpBB® Forum Software