- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Why does ^M appears at the end of the line?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 09:45 PM
тАО03-27-2006 09:45 PM
I notice the symbol "^M" appearing at the end of each line in my text file. What does it means? How can I get rid or prevent it from appearing? is there any implication if I remove them?
Best regards
Henry
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 09:47 PM
- Tags:
- dos2ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 09:49 PM
тАО03-27-2006 09:49 PM
Re: Why does ^M appears at the end of the line?
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=972302
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=364956
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 09:50 PM
тАО03-27-2006 09:50 PM
Re: Why does ^M appears at the end of the line?
Did you ftp the file to your server?
Change the transfer mode from ascii to binary to solve this problem
ftp>bin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 09:59 PM
тАО03-27-2006 09:59 PM
Re: Why does ^M appears at the end of the line?
the ^M is the way the system shows the difference in how UNIX systems and DOS systems interpret the carriage return at the end of the line.
Solutions as to how to remove/prevent the character are aplenty (see earlier answers).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 11:15 PM
тАО03-27-2006 11:15 PM
Re: Why does ^M appears at the end of the line?
I think the mode needs to be set to ascii when ftping file from DOS to Unix so that the ^M characters are interpreted by Unix as carriage return and do not appear as ^M in the files in UNIX, whereas if you use binary mode the file is ftpied in binary format and Unix does not do any interpretation of any of the characters.
So ascii is the mode required.
Henry,
Next - if you wish to remove the ^M characters from the file you have already got - edit the file using vi, then type the colon - : to go to command mode in vi and give following at colon prompt
s/^M//g
This will remove all the ^M characters .(Note to type the correct ^M character - use the following sequence of keys
Ctrl+V+Shift+M - the Ctrl+V will give you the control character ^ and shit+M will give the M)
Hope this helps.
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-27-2006 11:56 PM
тАО03-27-2006 11:56 PM
Re: Why does ^M appears at the end of the line?
it's
dos2ux file.name > new_file.name
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2006 12:24 PM
тАО03-28-2006 12:24 PM
Re: Why does ^M appears at the end of the line?
As noted, if you are running on HP-UX you have 'dos2ux' and 'ux2dos'.
The 'dos2ux' and 'ux2dos' commands read each specified file in sequence and write them to standard output, converting from DOS to UNIX format or from UNIX to DOS format, respectively.
If you are *not* on a HP server, you can make strip the carriage returns (^M) with this:
# perl -ni.old -e ' s,\015\012,\012,s; s,\032,,s; file
The above make a backup copy of "file" as "file.old" and performs the conversion.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-28-2006 01:13 PM
тАО03-28-2006 01:13 PM
Re: Why does ^M appears at the end of the line?
You generally get this when performing an FTP 'get' or 'put' of a file and you have not selected the proper file transfer mode.
When transferring files from Unix to DOS (Windows) systems and those files are text files, you may wish to manually set the file transfer mode to 'ascii'. That way, the carriage returns and line feed characters will be cleaned up during the FTP transfer.
If you forget (or get confused by all this nonsense), then just use the utility specified in another post (dos2ux) or you can use a vi command, if you are comfortable with that:
[ESC]:%s/[Ctrl-V][Ctrl-M]$//
This command says: for all lines in the file (%), substitute (s), the first pattern (the sequence ctrl-v,ctrl-m is how you get Ctrl-M in vi) -- only when it appears at the end of a record ($), with the second pattern (null).
--Good luck, Jeff