Recursively convert line endings with dos2unix + mac2unix

To recursively convert line endings from DOS \r\n and old macOS \r to Unix \n format in all files recursively, use dos2unix and mac2unix commands. For example, it’s not uncommonn that Matlab .m files shared among groups end up with DOS line endings, which can cause issues across different operating systems. When viewed with “git diff” or similar, files might have ^M characters at the end of lines, indicating DOS or old macOS line endings.

On Unix-like shell, use GNU Find to convert in place all .m files:

find . -type f -name "*.m" -exec dos2unix -e {} + -exec mac2unix -e {} +

Or with PowerShell:

Get-ChildItem -Recurse -Filter *.m | ForEach-Object {
    dos2unix -e $_.FullName
    mac2unix -e $_.FullName
}

Set Git to use the correct line endings to avoid line ending conflicts in Git repositories.