![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to send mail automatically in unix | rajan_ka1 | Shell Programming and Scripting | 7 | 05-30-2008 12:04 AM |
| Routes being automatically added | Conutmonky | UNIX for Dummies Questions & Answers | 1 | 02-28-2008 03:13 PM |
| extran NUll character added after end of line "\n" | arunkumar_mca | UNIX for Dummies Questions & Answers | 1 | 11-12-2007 09:23 AM |
| Vi opens automatically when i login to a unix box | ramky79 | AIX | 3 | 01-24-2007 07:43 PM |
| ftp file from Windows to Unix automatically | whatisthis | Shell Programming and Scripting | 4 | 11-14-2005 10:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I used Notepad to compile my txt file and then I transferred this file to UNIX. When I use vi to open the file, I found that at the end of each line there was a "^M" character.
In the original txt file there was not this character. Why this character would been added automatically in UNIX? |
| Forum Sponsor | ||
|
|
|
|||
|
the text file under unix is fifferent from m$ DOS,
if you use ftp to exchange text files between them, you should always use ascii model; if you use mcopy u should always add the -t switch or you may use this to trim the '^M' charater under unix if you already cp'ed the text file to unix: tr -d "\015" < hello.c > hello.unix.c |
|
|||
|
You could also do a global replace in vi. At the command prompt
(the 1,$s/ctrl-vm//g where ctrl-v means hold the control key while pressing the letter v. Then release them both and press the m key. The text at the command prompt should then look like 1,$s/^M//g This will strip the ^M which is a linefeed in DOS/Windows. Next time you should do as jApHEth said and ftp in ASCII mode. |
|
|||
|
In DOS ,the end of the line is indiacted by two characters to have compatability with type writer i.e enter ( new line feed) and carrige return (to bring the typewriter head to start position) but in unix only end of line is there with no carrige return so character
' ^ M ' gets appended at the end of line. |