-1

I'm learning bash and I tried to make a simple script that changes the directory and executes a command, like this:

#!/bin/bash
cd adf-elite-connector
<execute a command>

But I was getting the following error:

-bash: ./dc.sh: /bin/bash^M: bad interpreter: No such file or directory

If I removed the bin/bash header and have the following script:

cd adf-elite-connector
<execute a command>

I would get an error with a truncated directory name:

: No such file or directoryite-connector

Tudor
  • 2,224
  • 2
  • 21
  • 24
  • Possible duplicate of [-bash: ./my\_script: /bin/bash^M: bad interpreter: No such file or directory](https://stackoverflow.com/q/14219092/608639) – jww Aug 14 '19 at 09:50

1 Answers1

0

I was creating the script in windows and I was uploading the file to linux. End Of Line characters (EOL) differ between windows and linux. So all I had to do is convert EOL characters from windows to linux.

This can be done with Notepad++, going to Edit > EOL Conversion > Unix (LF)

After I uploaded the converted file, it would change the directory and execute the command without a problem.

Tudor
  • 2,224
  • 2
  • 21
  • 24