OpenBSD does not offer a dos2unix command. Why should it? The functionality is already available using the program “translate characters”.
Remove that pesky ^M by redirecting output through a tr:
tr -d '15' < <dirty dos file> > <cleansed file>
Where <dirty dos file> is the file with the pesky ^Ms. Make certain you specify a different filename for the <cleansed file>. You could have trouble if you don’t.
As an example, if you buddy June sends you an updated wordpress file they wrote on Windows called wp-awesomeness.php. Fix the file by executing the following command:
tr -d '15' < wp-awesomeness.php > wp-awesomeness-new.php
Confirm that the new awesomeness is what you want and replace the old file with the new file:
mv wp-awesomeness-new.php wp-awesomeness.php
Conversely, you could just write a shell script wrapper for the same command and install it in your bin directory as dos2unix.
Related posts: