Friday, 14 February 2014

How to use dos2unix, with example for the whole folder

If you always copy files from Window OS to Linux Based OS, and do compilation, you will always hit into this issue.
Where some weird error would occur, and it might complaint some weird symbol or text.

This is because when you copy from Window to Linux, the file format might not changed, depends on which tools you used to do the transfer.

Best way to ensure not to encounter any strange or weird issue due to Window file's format. Do the following command after you have FTP or copied the files over.

find . -type f -exec dos2unix {} \;
This will do recursive conversion of everything in the current folder and all its sub-folders.

If you just want to convert specific folders only. Replace the <folder> with your folder's name. Example below:
find <folder> -type f -exec dos2unix {} \;
i.e.  find myfolder -type f -exec dos2unix {} \;
That's it. Happy Coding.

No comments:

Post a Comment