LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c code from windows to linux - wich command? (https://www.linuxquestions.org/questions/linux-newbie-8/c-code-from-windows-to-linux-wich-command-371358/)

kotoko 10-09-2005 08:41 PM

c code from windows to linux - wich command?
 
Hi everyone!

I'm not quite sure if this question belongs here but I am a newbie I'm only asking this stuff because I'm learning C at school.

Anyway I need to take a text (c code) edited in windows and take it to linux. I know that there is a command to make all those anoying ^M^M disappear because the teacher told us in the class but I didn't wrote it down and I can't remember . . .

That was on Fedora core, am on slackware right now but I understood it was distro independent.

Can anyone help me?

macemoneta 10-09-2005 09:34 PM

You want dos2unix:

dos2unix -n infile outfile

paulsm4 10-09-2005 10:14 PM

"dos2unix" is a good suggestion.

You can also do with with "sed":

sed 's/^M//g' MYFILE > tmp.tmp
mv tmp.tmp MYFILE

.. or with vi:

vi MYFILE
<Esc>
:s/^V^M//g
:x
<= THE <ESC> KEY PUTS YOU IN COMMAND MODE
THE ":s/ / /" COMMAND DOES A GLOBAL SUBSTITUTE
<Ctl-V><Ctl-M> ALLOWS YOU TO ENTER THE "^M" (NEWLINE) CHARACTER

You can possible also simply ignore the issue.

"vi" (aka "vim" on Linux) doesn't show you the funky "^M" characters.
"wordpad" (aka "write.exe" on Windows) lets you deal with Unix files that don't have the "^M" delimiters.
And my favorite Windows text editor, Ultraedit, (as well, I'm sure, as most/all of the other programmers editors
out there) let you deal with Unix and/or Windows (and/or Mac!) files seamlessly:

http://www.ultraedit.com

'Hope that helps .. PSM


All times are GMT -5. The time now is 05:30 PM.