1. Install dos2unix (if not already installed)
On Windows with WSL (Ubuntu example):
sudo apt update
sudo apt install dos2unixOn Linux:
sudo apt install dos2unixOn macOS (with Homebrew):
brew install dos2unix2. Check the current line endings
You can check if the file uses Windows-style line endings:
cat -v sync-album.sh-
If you see
^Mat the end of lines → it’s Windows (CRLF). -
If no
^M→ it’s already Unix (LF).
3. Convert the file
dos2unix sync-album.sh-
This will replace all
CRLFline endings with Unix-styleLF. -
The conversion happens in-place by default.
4. Make the script executable
chmod +x sync-album.sh5. Run the script
./sync-album.sh- It should now run without errors like
/bin/bash^M: bad interpreter.
💡 Tip: If you want to convert multiple files at once:
dos2unix *.shBack References: