What is tilde (~) in Mac/Linux?

The tilde(~) expansion in Mac/Linux has several pathnames.12

  • 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/`

Leave a Reply

Your email address will not be published. Required fields are marked *