How to Convert Windows-style Line Endings to UNIX-style Line Ending

You can convert line endings of your script to UNIX format using a utility like dos2unix.

  1. Install dos2unix if it’s not already available on your system. You can use the package manager for your Linux distribution to install it.

  2. Open a terminal and navigate to the directory where your script is located.

  3. Run the following command to convert the line endings of your script to UNIX format:

    dos2unix some_bash_script.sh
    
  4. After the conversion, try running the script again:

    ./some_bash_script.sh
    

Alternatively, if you don’t have access to dos2unix or prefer not to use it, you can try manually converting the line endings using a text editor that supports the conversion. Save the file with UNIX-style line endings and then try running the script again.