dos2unix — Convert Windows Text Files to Unix Format

dos2unix converts text files from Windows line endings to Unix/Linux line endings. This is useful when shell scripts edited on Windows fail with strange errors.

Convert a file

dos2unix script.sh

After converting, make sure the script has execute permission if you want to run it directly.

chmod +x script.sh
./script.sh

Check file type

file script.sh

If the file shows CRLF line terminators, dos2unix is usually the right fix.

Leave a Comment