0

dos2unix takes filename as an argument. I need to make it generic so that it can take either a file or directories and then search recursively in directories and convert all files in the tree structure from dos to Unix. I am using KornShell (ksh). Please help

Thanks.

javaPlease42
  • 3,765
  • 3
  • 32
  • 56
ruby
  • 1
  • 1
  • 1

2 Answers2

6

Use find:

find file-path -type f -exec dos2unix {} \;
Prince John Wesley
  • 58,850
  • 11
  • 80
  • 91
0

I tried Prince John's answer on SunOS 5.10 with a KornShell, and it didn't work.

Apparently, because the dos2unix command was missing the output file, so it only printed to the stdout.

This modification to his answer worked for me.

find . -type f -exec dos2unix {} {} \;
Sekkuar
  • 346
  • 1
  • 9
  • 1
    Dos2unix is not part of the Unix standard. Their are many different implementations. People should always consult the man page first. – Erwin Waterlander Apr 15 '14 at 07:38
  • True. This is the man page shown in my system: http://docs.oracle.com/cd/E19253-01/816-5165/dos2unix-1/index.html – Sekkuar Apr 15 '14 at 18:14