LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-18-2013, 01:45 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
invisible character under Windows but visible under LINUX


I have a stranger thing:

I edit a file with an editor in Windows and it looks fine. But after I transport/copy this file to LINUX and as I open this file with vi, I find some unexpected characters.

For examle this file has the line in Windows
Code:
...
export http_proxy=http://$HTTP_PROXYHOST:$HTTP_PROXYPORT/
...
But under LINUX vi it looks as follow:
Code:
...
export http_proxy=http://$HTTP_PROXYHOST:$HTTP_PROXYPORT/^M
...
One can see the charater ^M now (this should the carrage return?). This can even not be seen with less or cat.

I am not sure if this is the problem of LINUX or a mistake as I edit this file under Windows? If this is the problem of LINUX, why the other lines without such ending?

I wonder how can I find out this under Windows before I transfer/copy this file to LINUX?

I've tried using the HEX-Editor but this doesn't help.

P.S.: After I run dos2unix over this file, the unwanted charaters are gone.

Last edited by thomas2004ch; 09-18-2013 at 02:01 AM.
 
Old 09-18-2013, 01:52 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
^M is the carriage return character used by windows (ascii 13). That's why it doesn't show when using windows.

Use the dos2unix command on the file to remove them (from linux)

I'm not a windows user, but it must be possible to save the file in a plain text format without the ^M
 
Old 09-18-2013, 01:52 AM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
the is a DOS EOL ( End Of Line )

many many ways to fix it
  • not use windows to write such files
  • use notepad++ in windows, saving with Unix EOL
  • use the dos2unix utility to convert the files to unix format
  • many others...

edit for convenience :
http://notepad-plus-plus.org/

Last edited by Firerat; 09-18-2013 at 01:57 AM.
 
1 members found this post helpful.
Old 09-18-2013, 10:53 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
This is normal for a text file transferred from Windows to Linux. Windows text files, and MSDOS as well, terminate each line with a "CARRIAGE-RETURN" and a "LINE-FEED" (two characters). Linux (and Unix and OS-X) terminate each line with only a LINE-FEED (one character). The original Mac's (not OS-X) terminate each line with a CARRIAGE-RETURN (one character).
 
Old 09-18-2013, 10:58 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Below is a webpage that explains what you're seeing. Actually, the webpage is trying to sell you their overpriced Windows text editor, but ignore that part and just read their description of end-of-line conventions and FTP's "ascii" and "binary" modes.

http://www.editpadpro.com/tricklinebreak.html
 
  


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
[SOLVED] mounted windows volume folders are hidden on linux, visible from mac or windows florenceit Linux - Software 4 10-11-2010 02:55 AM
Linux files invisible to windows computers linux hates me Linux - Networking 1 06-02-2009 12:49 PM
Invisible / Visible Package? freelanxer Linux - Enterprise 2 10-04-2006 07:11 PM
samba server visible for linux but invisible for windows morgwai Linux - Networking 7 08-22-2005 08:40 AM
Linux (Cups) printer visible to windows, invisible to linux boxes ? johnvoisey Linux - Networking 2 02-27-2004 02:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:20 AM.

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