I have a .sh
file and I want to execute it from shell without writing the extension.
What I did:
- I created a directory and added it to $PATH
- I gave to the file.sh chmod 711
- and the file contain #!/bin/sh (I tried also bash).
However when I try to execute myscript
without sh I get command not found
while if I try with myscript.sh
I get the right result.
How could I do?
I read also: How to run a shell script on a Unix console or Mac terminal? and executing shell script without calling sh implicitly but no solution
Result of ls -l
ls -l /Users/Mitro/scripts
total 8
-rwx--x--x 1 Mitro staff 22 Nov 26 10:25 myscript.sh
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/Mitro/scripts