Solved: Bash script and /bin/bash^M: bad interpreter: No such file or directory

Question:

I’m learning through this tutorial to learn bash scripts to automate a few tasks for me. I’m connecting to a server using putty.
The script, located in .../Documents/LOG, is:
And I executed the following for read/write/execute permissions
Then, when I enter ./my_script, I’m getting the error given in the title.
Some similar questions wanted to see these, so I think they might help:

/bin/bash


and

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/bin/mh


I tried adding current directory to PATH, but that doesn’t work..

Best Answer:

Run following command in terminal
Then try
It should work.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com