Why is the following wrong?$ cd ~/my databash: cd: ~/my data: No such file or directory$ cd ~/my databash: cd: ~/my data: No such file or directory$ cd ~/my data # works
double quotation with tilda expansion and backslash
bash
That how bash tilde expansion works:If a word begins with an unquoted tilde character (~), all of the  characters up to the first unquoted slash (or all characters, if there  is no unquoted slash) are considered a tilde-prefix.Lets assume your home directory is /home/user and you're currently in it, the first example:cd ~/my dataThis tries to cd into a directory with the path /home/user/~/my data/. Notice that ~ is a valid character in directory or file names.The second example:cd ~/my dataThis does the same as the first. If your wonder, it's because the slash is quoted, as stated in the citation above.The third example:cd ~/my dataThis does tilde expansion, because the slash is not quoted, and is therefore replaced by the contents of the $HOME environment variable. This changes to the directory /home/user/my data/.