Tilde not recognized in Mac terminal

2019-03-12 11:09发布

I have this weird situation on my Mac running OSX Lion where the ~ (tilda) does not go to my user directory. Instead when I type "cd ˜", I get:

-bash: cd: ˜: No such file or directory

Any advice on how to fix this?

8条回答
相关推荐>>
2楼-- · 2019-03-12 12:08

There are several characters like a tilde, and yours ˜ is not the one for the homedir ~ (close together: ˜ vs ~).

查看更多
神经病院院长
3楼-- · 2019-03-12 12:09

I've run into a related issue a couple of time that may have prompted the question: bash doesn't do tilde expansion on quoted filepaths (which you might use if you have spaces in the path). For example, cd "~/Documents/My Project" gets you the same error originally posted. The trick is to leave the tilde and the first slash outside the quote: cd ~/"Documents/My Project" works just fine.

查看更多
登录 后发表回答