The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
FreeBSD Support
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Previous Message  |  Next Message 
 Re: how to get rid of ^M in textfiles?
Author: Alan Fox 
Date:   23-02-02 19:50

Based on the last (good, working) perl script, I wrote a quick shell script that does all this for me.

The contents of the shell script are as follows:

#!/bin/sh
perl -p -i -e 's/\r\n/\n/s' $*

I named this script "dos2unix", placed it in the /usr/local/bin directory, and ran a quick "chmod 755 dos2unix" to get it working.

Just type "dos2unix file1.txt file2.txt ...", and it happily does its stuff.

The filename is optional. The name dos2unix collides with the name of another handy utility, also mentioned in this forum topic. I only named it "dos2unix" because I am used to dealing with that utility on Solaris systems, and I would not have to memorize any extra tool names. Note, by the way, that the usage of this tool differs from the original dos2unix.

 Reply To This Message  |  Forum List  |  Flat View   Newer Topic  |  Older Topic 

 Topics Author  Date
 how to get rid of ^M in textfiles?   new
g2k 13-08-01 18:28 
 Re: how to get rid of ^M in textfiles?   new
Erin 13-08-01 18:37 
 Re: how to get rid of ^M in textfiles?   new
g2k 13-08-01 19:05 
 Re: how to get rid of ^M in textfiles?   new
Daniel Schrock 14-08-01 22:06 
 Re: how to get rid of ^M in textfiles?   new
el_kab0ng 14-08-01 22:53 
 Re: how to get rid of ^M in textfiles?   new
Erin 13-08-01 18:40 
 Re: how to get rid of ^M in textfiles?   new
g2k 13-08-01 19:00 
 Re: how to get rid of ^M in textfiles?   new
Ryan Masse 13-08-01 18:46 
 Re: how to get rid of ^M in textfiles?   new
Dan Langille 13-08-01 20:47 
 Re: how to get rid of ^M in textfiles?   new
Dan Langille 13-08-01 20:54 
 Re: how to get rid of ^M in textfiles?   new
Jay 14-08-01 15:40 
 Re: how to get rid of ^M in textfiles?   new
el_kab0ng 14-08-01 17:41 
 Re: how to get rid of ^M in textfiles?   new
Jay 14-08-01 18:09 
 Re: how to get rid of ^M in textfiles?   new
Don 16-08-01 01:38 
 Re: how to get rid of ^M in textfiles?   new
Alan Fox 23-02-02 19:50 
 Re: how to get rid of ^M in textfiles?   new
Dan Langille 15-01-03 02:22 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org