- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to delete ^M characters from a file ?
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
Forums
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
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
тАО08-09-2002 02:21 AM
тАО08-09-2002 02:21 AM
I have a text file with each line terminated by a ^M character. I can see these at the end of each line if I open the file in vi. I've tried sed, tr and global search and replace in vi but the ^M still appears when I view the file. Is there a way of removing this control character?
Many thanks and regards,
Preet
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 02:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 02:30 AM
тАО08-09-2002 02:30 AM
Re: How to delete ^M characters from a file ?
# perl -pe 's/\r/\n/g' infile > outfile
If there is (M$ like) CRLF line endings
# perl -pe 's/\r$//' infile > outfile
If it is (Mac like) LFCR line endings
# perl -pe 's/^\r//g' infile > outfile
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 02:32 AM
тАО08-09-2002 02:32 AM
Re: How to delete ^M characters from a file ?
anyway you can the following filter :
cat
simple.
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 02:39 AM
тАО08-09-2002 02:39 AM
Re: How to delete ^M characters from a file ?
Within vi you can do it with ':g/^M/s///'.
The '^M' is one character and is composed by 'Ctrl-v Ctrl-m'.
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 03:12 AM
тАО08-09-2002 03:12 AM
Re: How to delete ^M characters from a file ?
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 07:00 AM
тАО08-09-2002 07:00 AM
Re: How to delete ^M characters from a file ?
dos2ux is the way to go. It's a little utility made just for this.
dos2ux
Typically this is caused by uploading a text file as binary instead of ascii.
Although I've seen some systems where unzip'ing a zip file containing text files ends up with the same problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 07:41 PM
тАО08-09-2002 07:41 PM
Re: How to delete ^M characters from a file ?
Please try
# cat infile | col -b > outfile
This can be helpful when you'd like to save man pages into an ascii file.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-11-2002 04:15 AM
тАО08-11-2002 04:15 AM
Re: How to delete ^M characters from a file ?
Here is the anwer to your question. I encountered the same problem with a program I was sent a few months ago. The origin of the problem was the way the programmers compiled the code, so when the files were sent to me in a zip file, it did not matter how I sent (ftp) them to the Unix server I am using, they all had the metacharacter. You can find the solution here:
http://icarus.weber.edu/home/bob/cs213/rm_ctr_m.html
You may also want to look at this forum discussion:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xae5f7d4cf554d611abdb0090277a778c,00.html