I tried running a script file using bash but it showed an error
bash-3.2$ example.sh : command not found
I also tried
ls -l example.sh
I found that it was not executable, so I used
sudo chmod 777 example.sh
I again tried running it but same error was coming. I double checked that I am in the same folder as the file using ls. But still I am not able to execute the script file.
I finally tried making a dummy script file and running it , and found the same error
I think there is some problem with BASH. Can some one help me with what is the problem?
I am working on redhat, bash was already installed in my system
Since I am newbie on linux any help would be appreciated
bash search for commands in your
$PATH. Apparently the current directory,., is not in your$PATH. (This is a good thing; having.in your$PATHis insecure.)You’ll need to specify a directory name. Just type:
Incidentally, doing:
is two kinds of overkill. First, you don’t need to use
sudo; usesudoonly when you actually need to. Presumably your personal account owns the file, so you can just usechmoddirectly.Second,
777is way too permissive. It allows anyone on the system to read, execute, or modifyexample.sh. (If you’re the only person on the system it may not matter much, but it’s still a bad habit.) Typically you should use755for directories and for files that need to be executable, and644for files that don’t need to be executable.Or just use
to set execute permission (your umask will prevent that from setting the permissions too loosely).