0

Apologies for the very basic question.

I am trying to do something for a given absolute path and all its parent folders up to /. For the sake of the example here we'll just echo the path (I know that a solution to echoing the paths has been posted here, but please bear with me).

The following does not work. Moreover, after running that, ls and dirname are not found.

leo# cd /mnt/data/
leo# dirname /mnt/data
/mnt
leo# echo "Enter absolute path"; read path; until [[ "$path" == "$(dirname "$path")" ]]; do echo $path; path="$(dirname "$path")"; done
Enter absolute path
/mnt/data/
zsh: command not found: dirname
/ifs/data/
zsh: command not found: dirname
zsh: command not found: dirname
leo# ls
zsh: command not found: ls
leo# dirname
zsh: command not found: dirname
leo# echo ah
ah
leo#
leo
  • 103
  • 3
  • 2
    Don't use the name `path` for your variable in zsh - it inherits (from csh) a special meaning. See for example [What is the difference between $path and $PATH (lowercase versus uppercase) with zsh?](https://unix.stackexchange.com/questions/532148/what-is-the-difference-between-path-and-path-lowercase-versus-uppercase-with) – steeldriver Aug 28 '22 at 17:16
  • 2
    ... or perhaps more directly relevant [zsh script cannot find commmands](https://unix.stackexchange.com/questions/646904/zsh-script-cannot-find-commmands) – steeldriver Aug 28 '22 at 17:19
  • Thank you @steeldriver – leo Aug 28 '22 at 17:21

0 Answers0