LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-09-2005, 08:41 PM   #1
kotoko
LQ Newbie
 
Registered: May 2005
Posts: 8

Rep: Reputation: 0
Unhappy 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?
 
Old 10-09-2005, 09:34 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You want dos2unix:

dos2unix -n infile outfile
 
Old 10-09-2005, 10:14 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C program code to execute linux-command supermichou_fr Linux - Software 4 08-01-2012 08:25 AM
command for compling C code in linux fastian Linux - Networking 3 02-15-2005 05:57 AM
how to invoke a linux command inside a java code ? kusum Linux - Software 2 11-23-2003 01:19 PM
C program code to run a Linux command line Linh Programming 10 06-11-2003 01:59 PM
C program code calling a Linux system command Linh Programming 1 06-05-2003 01:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration