"find" help

Can someone please show me how to use the find command to search a directory and all subdirectories (all files) and replace all instances of \r\n with \r?  I've got some windows text files that I need to convert to unix style.  Any other method to easily do this would also be acceptable.

Who is Participating?
avizitConnect With a Mentor Commented:
getting "dos2unix" is preferable cos the other solutions ( check http://mikeage.net/content/tips/linux/dos2unix.php )
creates a new file , so you have to save that as tempfile and then move the tempfile over the original file . hence your script becomes messy .

dos2unix and unix2dos works on the same file ..hence better IMHO
there is a better way to do this if your system has it ..

the command to use is "dos2unix"  


find . -type f | xargs dos2unix

dirtdartAuthor Commented:
I'm running Slack 10 and it doesn't look like it's installed.  Is this something I can download?
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

be warned not that you should do that only for txt files

so maybe you can modify it to

find . -type f -name "*.txt" | xargs dos2unix

if all your files have extension .txt ,
dirtdartAuthor Commented:
Thanks.  I just found a download site.  They're all php files, so it should work the same.  Let me give it a try when I get my files transferred and if it works, I'll come back and reward the points.
you can get dos2unix sources from

or if you can install using rpm you can get the dos2unix rpm from rpmfind.net
dirtdartAuthor Commented:
Worked like a charm!  Thanks for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.