When we got /bin/bash^M: bad interpreter: error means script created on windows system via editor

(Windows made script run in linux /bin/bash^M: bad interpreter: No such file or directory [duplicate])

in that case we have to run below and replace

Run following command in terminal
sed -i -e 's/\r$//' scriptname.sh
Then try
./scriptname.sh
It should work.