Results 1 to 2 of 2
Hello ,
I am new to use z-shell .I am trying to understand a script written in Z-Shell .Can anybody plz tell me what is the meaning of command "cd ...
- 09-26-2007 #1Just Joined!
- Join Date
- Nov 2006
- Posts
- 2
Zshell
Hello ,
I am new to use z-shell .I am trying to understand a script written in Z-Shell .Can anybody plz tell me what is the meaning of command "cd $0:h"
- 09-26-2007 #2Just Joined!
- Join Date
- Aug 2007
- Posts
- 37
The short answer is that it changes the current directory to the directory in which the script resides.
$0 is a positional parameter that, in this context, expands to the path of the script which is currently running.
:h is one of a pair of modifiers (:h head, and :t tail).
If the path to the script that you are running is /home/shwetank_gupta/bin/myscript.sh then :t is the 'tail' of the path: myscript.sh, and :h is the rest of the path i.e. /home/shwetank_gupta/bin.
So "cd $0:h" would change directory to /home/shwetank_gupta/bin.


Reply With Quote