What is the difference between
. (or ..) and
~ character with respect to how they are treated by the bash?
If i use
~ character, bash expands it to absolute path but if is use
. (or ..) bash does not expand it to absolute path?
My pwd is home directory. Now, when i run the command:
ls '.' (or ls .) it shows me the contents of the pwd but if i run the command:
ls '~', it gives the error that the file or directory does not exists.
~ is expanded by shell before passing it to the
ls command but
. is not.
. not a special character? When is
. (or ..) treated as special character and expanded by the shell?
~is only special when it is unquoted and when it is the first character of a word -- gnu.org/software/bash/manual/bash.html#Tilde-Expansion
..are not special to bash in any way, so they are the same quoted or unquoted.