tag:blogger.com,1999:blog-8712770457197348465.post8382013347583972961..comments2024-03-28T01:04:16.249-07:00Comments on Javarevisited: How to Remove CTRL-M characters From a File in UNIX and Linux? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8712770457197348465.post-86438094590304419242021-02-19T07:22:16.921-08:002021-02-19T07:22:16.921-08:00Hello Murali, that's nice, thx for sharing thi...Hello Murali, that's nice, thx for sharing this useful tip with us. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-8300020109589659452021-02-18T15:31:39.748-08:002021-02-18T15:31:39.748-08:00Hi, we can remove ^M characters with tr command. ^...Hi, we can remove ^M characters with tr command. ^M is \r\n.<br />Hence, if a file say, file1 has ^M chars., then we can remove as below:<br />tr -d '\r' < file1 > /tmp/abc$$.txt; mv /tmp/abc$$.txt file1Muralinoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-28963998551979035302016-10-06T02:54:29.617-07:002016-10-06T02:54:29.617-07:00Hello!
Another way with vi:
:set ff=unix
And you...Hello!<br />Another way with vi:<br /><br />:set ff=unix<br /><br />And you can save your files without ^M<br /><br />RegardsXakovhttps://www.blogger.com/profile/06593253122586074677noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-4017553265448937392016-09-25T07:33:12.760-07:002016-09-25T07:33:12.760-07:00The problem with dos2unix is that it isn't ins...The problem with dos2unix is that it isn't installed natively on all systems (not sure it is in any but only had to install it on one).<br /><br />I had to look it up but you can also use the tr command as follows:<br /><br /> tr -d '^M' file2<br />or <br /> tr -d '\015' file2<br /><br />A couple of additional ways found at http://www.theunixschool.com/2011/03/Joelhttps://www.blogger.com/profile/02202249781984033516noreply@blogger.com