As an admin when you run different scripts and get this error, basically you will need to change or convert the script, probably the type format of the script is for Windows OS and need to be converted to allow the execution on Unix/Linux environments, sometimes it happens otherwise.
You can do it two ways,
You can use notepad ++ to change the format of the file, use the following steps.
> Open Notepad ++
> Load the script
> Go to Edit
> EOL Conversion
> You can check on the bottom of the file the type format of the script. (check following screenshot)
> Select UNIX/OSX Format
> Save file
Note: If the script is for UNIX/Linux and need to be executed on Windows OS, use the “Windows Format” option.
Also, dos2unix is a Linux tool that allow you to convert the file format of the script, to be executed on Windows OS or UNIX/Linux environments. If you need to convert to be executed on Windows please check unix2dos.
Only need to use the command like the following example,
[root@localhost github]# ./stweak100_2.sh
-bash: ./stweak100_2.sh: /bin/bash^M: bad interpreter: No such file or directory
[root@localhost github]# dos2unix stweak100_2.sh stweak100_2_UNIX.sh
dos2unix: converting file stweak100_2.sh to Unix format …
dos2unix: stweak100_2_UNIX.sh: No such file or directory
dos2unix: Skipping stweak100_2_UNIX.sh, not a regular file.
If you see something like the previous example, it worked, now run the script and you will not get the initial error.
“-bash: ./stweak100_2.sh: /bin/bash^M: bad interpreter: No such file or directory”
For more information, use man pages.