0

What I did on Windows was create a .bat file and put this in tree "%CD%" > "%CD%\file.txt" /A /F. I know that %CD% isn't available in macOS. %CD% takes the path where the .bat file is located.

I tried using pwd but that only takes /Users/[current_user] and that's not what I wanted. Is there a way to get the path where the .command file is located?

Before saying cd path/to/dir ... the path is unknown. It has to take the path where it currently is.

  • You can use the find command – Raman Sailopal Mar 26 '21 at 17:23
  • Do ["How can I get the source directory of a Bash script from within the script itself?"[(https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel) and ["Reliable way for a Bash script to get the full path to itself"](https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself) answer your question? Also, check out [BashFAQ #28: "How do I determine the location of my script? I want to read some config files from the same place."](http://mywiki.wooledge.org/BashFAQ/028) – Gordon Davisson Mar 26 '21 at 17:41

0 Answers0