I would like to run ".sh" files in a directory without having to navigate to that directory, as shown below.
Me trying to run a .sh file, that is not in my current directory:
root@naveen-hp:/home# bash start-master.sh
bash: start-master.sh: No such file or directory
Me trying to run a .sh file by specifying it's location:
root@naveen-hp:/home# bash /usr/local/bin/spark/sbin/start-master.sh
starting org.apache.spark.deploy.master.Master, logging to /usr/local/bin/spark/logs/spark-root-org.apache.spark.deploy.master.Master-1-naveen-hp.out
So, is there a way to have terminal to also look in /usr/local/bin/spark/sbin/
directory, not just the pwd, when a request to run a .sh file is sent?
/usr/local/bin/spark/sbin
whenever i run a .sh file. – Naveen Reddy Marthala Oct 30 '20 at 11:32bash
(orsh
, orcsh
, or ...) explicitly - it's the job of the shebang to decide what interpreter to use. Once you make the script executable, THEN you can add/usr/local/bin/spark/sbin/
to yourPATH
. The shell only searches your path for programs, not for arguments to programs - which is what you usebash
explicitly. – steeldriver Oct 30 '20 at 12:21