This question already has an answer here:

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;

myname(i.e. root directory)

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.

marked as duplicate by Scott, Jeff Schaller bash Feb 22 at 11:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


./Users/myname/bash_scripts/create_py_dir.sh is not an absolute path.

A . is a reference to the current folder.

This would be an example of an absolute path: /Users/myname/bash_scripts/create_py_dir.sh

(assuming the directory Users exists in the top level of the file system)

  • Such a simple nuance, I am embarrassed I did not notice that. Thank you! – Jon Kennedy Nov 13 '18 at 16:06
  • You're welcome! If this solved your problem, please accept the answer. – Panki Nov 13 '18 at 16:22
  • 1
    To put a finer point on it: An absolute path starts with /; anything else will be a relative path. – DopeGhoti Nov 13 '18 at 18:16
  • @panki, sort I was at work all day and this is the first chance I have had to accept it. – Jon Kennedy Nov 14 '18 at 2:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.