I have a file in my root directory called bash_scripts
and within it I have a file called create_py_dir.sh
. At present the only command in the shell script is pwd
, which I am using just to ensure it is working correctly. The directory structure is shown below;
desktop
|
myname(i.e. root directory)
|
bash_scripts
|
create_py_dir.sh
If I cd
to the same directory as the scripts and run a pwd
command it tells me that the file is in the directory /Users/myname/bash_scripts
. So lets say that I go back to the root directory and up one directory to the desktop via cd ../desktop
and from there I run the script via relative path with ./../bash_scripts/create_py_dir.sh
, the scripts works just fine. However, if I try to execute it via an absolute path with ./Users/myname/bash_scripts/create_py_dir.sh
I get the following error, ./Users/myname/bash_scripts/create_py_dir.sh: No such file or directory
. I think I have a fundamental understanding problem with how to run shell scripts from absolute paths.
/
; anything else will be a relative path. – DopeGhoti Nov 13 '18 at 18:16