Reputation: 13262
My script, learn-fork.sh
, is the following, plus a lot of comments (which will be un-commented once I get the test lines to work)
#!/bin/bash
echo "Running from ${0}"
In addition to that file, I have another file that shows in Finder as learn-fork
(no extension) but that shows up in the terminal as learn-fork.sh-e
Here are the permissions on those files.
-rwxr-xr-x 1 TuzsNewMacBook admin 250 Jan 1 18:25 learn-fork.sh
-rwxr-xr-x@ 1 TuzsNewMacBook admin 307 Jan 1 13:38 learn-fork.sh-e
Running learn-fork.sh
works.
Running learn-fork
gives -bash: learn-fork: command not found
.
Upvotes: 0
Views: 69
Reputation: 295298
If you want to invoke it with the command learn-fork
, name the file learn-fork
.
Exactly that, no extension whatsoever. Not learn-fork.sh
, or learn-fork.sh-e
, or anything else -- just learn-fork
.
Treating a file extension as something separate that's not really part of a name is a Windows-ism; UNIX-y folks (and UNIX-y operating systems) don't believe in it. Thus, if you want a command named foo
, the executable or script associated must be named foo
, not foo.anything
.
And it must be marked as executable with chmod +x foo
AND called with a correct path reference, either ./foo
or /path/to/foo
OR where /path/to
is included in the PATH variable, i.e. export PATH="/path/to:$PATH"
.
Upvotes: 3