my terminal isn't capable of finding any file or directory if I type in the name of the file or directory which start with "~/." or "~/".

I have OS El Capitan, XCode 8 is installed, so is XCode Command Lines Tools.


As requested, this is the full command line I put( I tried several):

   cd ~/.bash_profile_common
   cd ~/usr
   cd ~/local
   cd ~/bin 

And finder doesn't seem to find them either.

After typing

   echo $HOME

I get


~ (tilde) expands to the value of the variable HOME which is set by the process login or to the value set in one of your shell's config files.

From the man pages:

HOME - The home directory of the current user; the default argument for the cd builtin command. The value of this variable is also used when performing tilde expansion.

Tilde Expansion - If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME. If HOME is unset, the home directory of the user executing the shell is substituted instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name.

In your case (assuming you have not changed HOME), using ~/bin, ~/usr, ~/local is expanding them to /Users/myname/bin, /Users/myname/usr, /Users/myname/local.

If what you want is in the root folder of your system, don't put the ~ (leave just / at the front).

References: man page for bash/man bash

  • I see my mistake. It now definitely works, thank you! But it is still unable to find the bash_profile_common file,what could I do! – John Mayne Jul 25 '16 at 20:10
  • @Edward that is not a standard file. Did you create it? – NetherLinks Jul 25 '16 at 20:10
  • No, I never created. It was suggested that I should edit it, due to some compilation problems. I assumed it would be created during the installation of the compiler. I think I will head towards stackoverflow forum and ask if it's normal that I am unable to find this file. – John Mayne Jul 25 '16 at 20:14
  • Where was that suggestion - you are going to need to quote it for any chance that your question won't be closed on SO and even then I expect it his off topic there. – user151019 Jul 25 '16 at 20:21
  • @edward please ask a new question about the bash_profile_common thing. Be sure to include links etc to the instructions you are following. Or just use ~/.bash_profile instead :-) – nohillside Jul 26 '16 at 5:50

You can also find a good explanation of the standard Unix directory layout with man hier at the shell prompt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .