- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Delete control M character using tr command.
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
тАО09-25-2006 03:02 AM
тАО09-25-2006 03:02 AM
Delete control M character using tr command.
tr -d '\r' test.dat > test1.dat
2) How to get only the records which has control M in it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 03:06 AM
тАО09-25-2006 03:06 AM
Re: Delete control M character using tr command.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 03:06 AM
тАО09-25-2006 03:06 AM
Re: Delete control M character using tr command.
:%s/
it will remove all ^M character in that file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 03:08 AM
тАО09-25-2006 03:08 AM
Re: Delete control M character using tr command.
how about:
tr -d "\015" < test.dat > test1.dat
Don't forget, to get the ^M in UNIX command you have to use CTRL+V CTRL+M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 03:31 AM
тАО09-25-2006 03:31 AM
Re: Delete control M character using tr command.
Yet another way is:
# perl -pe 's/\r\n/\n/;s/\032//' file
This handles not only carriage-return characters (^M) but also any end-of-file character (^Z).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 04:19 AM
тАО09-25-2006 04:19 AM
Re: Delete control M character using tr command.
Unlike its bigger brother sed the tr command requires this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 05:01 AM
тАО09-25-2006 05:01 AM
Re: Delete control M character using tr command.
i just left '<' before test.dat
tr -d '\r' test.dat > test1.dat
tr -d '\r' < test.dat > test1.dat
this worked for me...
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 05:19 AM
тАО09-25-2006 05:19 AM
Re: Delete control M character using tr command.
cat test.dat |col -b > test.dat.1
or
col -bx test.dat test.dat.1
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 11:21 AM
тАО09-25-2006 11:21 AM
Re: Delete control M character using tr command.
Now if you are sharing directories between dissimilar systems, the same rule holds true. The PC files appear exactly as they exist on each system. A Unix file will have black squares at the end-of-line when viewed in Notepad, and a PC file will have CTRL-M's when viewed in Unix.
What to do? Well, there's no way to get t5he two different OS's to change so you'll have to translate whichever way you need. The 2 commands are:
dos2ux
and
ux2dos
(there's no similar commands on a PC).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2006 12:13 PM
тАО09-25-2006 12:13 PM
Re: Delete control M character using tr command.
To add to Bill's comments, while 'dos2ux' and 'ux2dos' are UNIX commands, Perl runs on virtually any platform. Hence on a UNIX or on a Microsoft Windows server the following are true:
In lieu of 'dos2ux' use:
# perl -pe 's!\r\n!\n!;s!\032!! if eof' file
...and in lieu of 'ux2dos' use:
# perl -pe 's!\n!\r\n!s;END{print "\032"}' file
Regards!
...JRF...