Every time I run a script using bash scriptname.sh
from the command line in Debian, I get Command Not found
and then the result of the script.
The script works but there is always a Command Not Found
statement printed on screen for each empty line. Each blank line is resulting in a command not found.
I am running the script from the /var
folder.
Here is the script:
#!/bin/bash
echo Hello World
I run it by typing the following:
bash testscript.sh
Why would this occur?
bash -x scriptname.sh
to trace the error. – In my case it was a sh-file saved under Windows with VSCode and line endings as "CRLF". In VSCode in the bottom right corner you can change the line terminator from "CRLF" to "LF". Uploaded this file and could execute it finally withbash scriptname.sh
.