What is tilde (~) in Mac/Linux?

The tilde(~) expansion in Mac/Linux has several pathnames.[ref]GNU Bash: Tilde Expansion[/ref][ref] The Magic ~: Bash Tilde Expansion with 5 Examples [/ref]

  • It could be ${HOME} if you do not specify the username.
    If you specify the user, it will expend the home directory of the user.
    For example,

    $ echo ~
    $ echo ~otheruser
  • It contains the working directory by +/-
    For example,

    $ echo ~+
    $ echo ~-

In shell, if you want to expand it,

EXPAND_PATH=`eval echo ~otheruse/bin/`