Suppose I have a bash file called myBash.bash
. It resides in:
/myDirect/myFolder/myBash.bash
Now I want to use the string /myDirect/myFolder
(the location of myBash.bash
) inside the script. Is there a command I can use to find this location?
Edit: The idea is that I want to set-up a zip-folder with code that can be started by a bash script inside that zip-file. I know the relative file-paths of the code inside that zip-file, but not the absolute paths, and I need those. One way would be to hard-code in the path, or require the path of the file to be given as a variable. However I would find it easier if it was possible for the bash-file to figure out where it is on its own and then create the relevant paths to the other file from its knowledge of the structure of the zip-file.
pwd
returns your current directory (from where you run the scirpt) not the scripts location. And just for clarification: it's about bash scripting, which is part of ubuntu, but isn't it more about programming then the distribution itself? – Sethos II Mar 17 '17 at 08:52cat /foo/bar | bash
. – pipe Mar 17 '17 at 20:54