- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Removing carriage return control characters from a...
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
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
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
10-17-2001 11:56 AM
10-17-2001 11:56 AM
I have an ASCII file with carriage return control characters. When I browse the file in vi it looks like this:
line 1 of text^M
line 2 of text^M
How can I remove the carriage return control characters so that I'm left with:
line 1 of text
line 2 of text
Thanks,
Paul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 11:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 12:01 PM
10-17-2001 12:01 PM
Re: Removing carriage return control characters from an ASCII file
You can easily deal with this with the 'dos2ux' (and inversely, with the 'ux2dos') utilities. See the man pages for more information:
# dos2ux oldfile > newfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 12:08 PM
10-17-2001 12:08 PM
Re: Removing carriage return control characters from an ASCII file
Another variation on the same theme:
cat oldfile | tr -d "\015" > newfile
tr -d will delete the CR's (octal 15's)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 12:11 PM
10-17-2001 12:11 PM
Re: Removing carriage return control characters from an ASCII file
Try this
sed 's/^M//' FILENAME > NEWFILE
or
use
# dos2ux /tmp/myfile > /tmp/myfile.new
Good luck
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 12:14 PM
10-17-2001 12:14 PM
Re: Removing carriage return control characters from an ASCII file
:1
:s/ctrl-Vctrl-M$//999999
note ctrl-V and ctrl-M will redraw into ^M - don't forget the $ sign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2001 12:21 PM
10-17-2001 12:21 PM
Re: Removing carriage return control characters from an ASCII file
As you can see there IS more than one way to skin a cat. If you got the file via FTP from a Windows environment using binary mode you'd get the ^M. Use ascii mode and FTP takes care of the translation for you. Otherwise, dos2ux is great.
Darrell