How to convert some files from dos format to unix

How Chen picture How Chen · Feb 21, 2013 · Viewed 7.7k times · Source

I know how to change file format from dos to unix by use dos2unix, but how can I change ALL the files will under a directory tree. Can dos2unix change files recursively?

for example, I have some files like following:

TOPDIR
|
+-----dir1
|      |
|      +---file1,file2, file3
|
+-----dir2
       |
       +---file4,file5

How can I change them in one time, or use some shell scripts?

Answer

Andrey Dmitriev picture Andrey Dmitriev · Feb 21, 2013

better to do find /path -type -f -exec dos2unix '{}' \;