I typically use cd Directory/Directory/
to point to the shell directory and then type bash shell.sh
, but I was wondering if there is an easier way to execute my shell & the location with one line? I do bounce to different folders often.
Example:
unix folder with a shell script named alpha
cd Desktop/unix
bash alpha.sh
Best Answer
If you set a script file executable:
And include the appropriate shebang (
#!/bin/bash
) at the top, you do not have to invoke it withbash
. Seeman chmod
for an explanation ofo+x
; you may prefera+x
.As for the path, you can add that as per Rahul's suggestion, or you can do something similar without adding it to your $PATH, eg:
Now anything executable in there can be used: