When you type sh somescript.sh
, the system looks for sh
in the path not somescript.sh
.
Then the system finds sh
and passes the argument somescript.sh
to it. Then sh
looks for somescript.sh
in the current folder or in the specified folder ~/bin/
if you typed
sh ~/bin/somescirpt.sh.
To make the system look for somescript.sh
in the path use it directly as a command, without the sh prefix. In other words, type in the terminal:
somescript.sh
For that to work, somescript.sh
needs located in a folder in the path, in this case ~/bin/
and it needs to be executable, as others have pointed out. I include the command below for completeness.
chmod +x ~/bin/somescript.sh
Also see How do I run .sh files? and
How to run scripts without typing the full path?
Hope this helps
sh <scriptname>
would be:<scriptname>