Change DOS format to linux

Change DOS format to linux

Post by Bob Ta » Tue, 16 Apr 1996 04:00:00



Hi, I'm trying to export my DOS C programs into linux, when I copied my
source code to linux, there are annoying ^M at the end of each line. I
remember I read some news telling you how to get rid of ^M in linux,
however I can't recall the precise steps, is there anyone can help me
through this problem?

Thanks in advance!

Bob Tang

 
 
 

Change DOS format to linux

Post by Mr Stuart Lamb » Tue, 16 Apr 1996 04:00:00


: Hi, I'm trying to export my DOS C programs into linux, when I copied my
: source code to linux, there are annoying ^M at the end of each line. I
: remember I read some news telling you how to get rid of ^M in linux,
: however I can't recall the precise steps, is there anyone can help me
: through this problem?

Easy. There's a program (script?) "fromdos" (IIRC) that'll do this for
you. I don't know if it's a standard script, or if it's just available
through slackware. The alternative is the following sequence:

vi filename
:1,$s/<ctrl-V><ctrl-M>$//
ZZ

and they'll be removed. (you can probably use sed or something similar
to achieve the same result, but I haven't learnt the syntax for it yet;
similarly, I'm sure there's some line expression that's shorter than
1,$ - but I don't know it offhand. It's a case of what you're used to.)

--
I now have a .sig of my vewwy own. I shall hug him, and love him,
and call him George.

 
 
 

Change DOS format to linux

Post by Bram van den Hou » Tue, 16 Apr 1996 04:00:00



> Hi, I'm trying to export my DOS C programs into linux, when I copied my
> source code to linux, there are annoying ^M at the end of each line. I
> remember I read some news telling you how to get rid of ^M in linux,
> however I can't recall the precise steps, is there anyone can help me
> through this problem?

> Thanks in advance!

> Bob Tang


Well Bob, I got the same problem here.
I maintain a WebSite at home in Win 95 and have to export the
html-files to a SGI. I recently found this neat little DOS-program,
which does the conversion for you.
I have it attached to this document.

I hope I have been of any help,

Cheers,

Bram .. Dutch Snooker Home Page

URL : http://asterix.urc.tue.nl/~bwaabgh/

  DOSCVT24.ZIP
20K Download
 
 
 

Change DOS format to linux

Post by Ross Bagle » Tue, 16 Apr 1996 04:00:00



> Hi, I'm trying to export my DOS C programs into linux, when I copied my
> source code to linux, there are annoying ^M at the end of each line. I
> remember I read some news telling you how to get rid of ^M in linux,
> however I can't recall the precise steps, is there anyone can help me
> through this problem?

Put the following in a file:  (don't include the "---" lines)

---include d2u---
#!/bin/sh
if [ "$1" = -c ]; then
  cat
else
/ sed -e s/$/
fi
# the ``echo -ne'' assumes that /bin/sh is really bash
echo -ne \\f
---end d2u---

Then do a "chmod +x <filename>" where <filename> is replaced
with whatever you called it.

Now use it.  If you called it "d2u":

% d2u < dos.txt > unix.txt

-- Ross Bagley      http://isdn33.eng.uc.edu/~rabagley
I do happen to speak for the owner of this computer...

 
 
 

Change DOS format to linux

Post by Christopher Morro » Tue, 16 Apr 1996 04:00:00


: Hi, I'm trying to export my DOS C programs into linux, when I copied my
: source code to linux, there are annoying ^M at the end of each line. I
: remember I read some news telling you how to get rid of ^M in linux,
: however I can't recall the precise steps, is there anyone can help me
: through this problem?

Check to see if your system has todos and fromdos (it should).  They use
standard input and output, so you use the redirection operators with it.
For example:

fromdos < dos_text_file > new_text_without_those_^M_characters

--
  ___ _        _                             __  __

| (__| ' \| '_| (_-< "I can see clearly now | |\/| / _ \ '_| '_/ _ \ ' \/ -_)
 \___|_||_|_| |_/__/ the brain is gone..."  |_|  |_\___/_| |_| \___/_||_\___|

 
 
 

Change DOS format to linux

Post by Jeffery Ch » Tue, 16 Apr 1996 04:00:00


: Hi, I'm trying to export my DOS C programs into linux, when I copied my
: source code to linux, there are annoying ^M at the end of each line. I
: remember I read some news telling you how to get rid of ^M in linux,
: however I can't recall the precise steps, is there anyone can help me
: through this problem?

how about
tr -d \r < infile > outfile?
at your shell prompt?

--
|======================================================|
| Jeffery Chow   3rd year Computer Science, UBC        |
|------------------------------------------------------|
| Home Page: http://www.ugrad.cs.ubc.ca/spider/j8g1    |

| "Badgers? We don't need no STINKING BADGERS!"        |
|======================================================|

 
 
 

Change DOS format to linux

Post by Ulrich Quil » Wed, 17 Apr 1996 04:00:00



> Hi, I'm trying to export my DOS C programs into linux, when I copied my
> source code to linux, there are annoying ^M at the end of each line. I
> remember I read some news telling you how to get rid of ^M in linux,
> however I can't recall the precise steps, is there anyone can help me
> through this problem?

Well, there is a program called 'dos2unix' which does exactly what you need.
If I'm not completely mistaken, it's not only available here on the SUN but
also back home under Linux.

Hmm, maybe it's contained in some utility package ?!?
Sorry, if so, I have to look up the reference.

--Ulrich

------------------------------------------------------------------------------
Dipl.Phys. Ulrich Quill                         Dept. of Neurophysiology
Tel: +49-(0)234-700-6955                        Ruhr-Universitaet Bochum

 
 
 

Change DOS format to linux

Post by Richard Hir » Wed, 17 Apr 1996 04:00:00




Quote:>: Hi, I'm trying to export my DOS C programs into linux, when I copied my
>: source code to linux, there are annoying ^M at the end of each line. I
>: remember I read some news telling you how to get rid of ^M in linux,
>: however I can't recall the precise steps, is there anyone can help me
>: through this problem?

>how about
>tr -d \r < infile > outfile?
>at your shell prompt?

Better put single quotes round that \r, otherwise you just loose all the
'r' characters!

--