I tried cd . ~ in terminal and I saw the same result as when I type cd ~ .
I want to know how this is done. Or better to say what is the priority of the arguments which comes after a command?
I tried cd . ~ in terminal and I saw the same result as when I type cd ~ .
I want to know how this is done. Or better to say what is the priority of the arguments which comes after a command?
You saw the same result because I'm sure that you test those commands from your home directory which is /home/your_username equivalent with ~ - see Tilde Expansion, or $HOME environment variable. To test properly, you should use:
cd / ; cd . ~
and:
cd / ; cd ~ .
In general if you use:
cd first_directory second_directory
you will change the shell working directory to first_directory, not to second_directory, so the second argument in the cd command is ignored (see also help cd to understand better).
And the . (dot) in this case is equivalent with the path of the shell current working directory which is given by pwd command (see Commandline shortcut for current directory similar to ~ for home directory?).
So cd . ~ is equivalent with cd . which is equivalent with cd $(pwd) and cd ~ . is equivalent with cd ~ which is equivalent with cd $HOME.
It gives the same result because you're running them from your home directory. Try moving to /tmp to observe a different behaviour.
Only the first positional parameter of the cd command is taken into account:
cd: usage: cd [-L|[-P [-e]]] [dir]