What does the ~
mean in an absolute file path?
I see this in the output of things like build scripts but the path does not exist.
What does the ~
mean in an absolute file path?
I see this in the output of things like build scripts but the path does not exist.
Normally it means the user's home directory e.g. ~mike/
would be the user mike
's home directory, ~/
would be your own home directory. However, it is unclear to me whether ~/
and ~mike/
should be considered absolute or relative; it seems to depend on the definition given (if anyone can come up with an authorative reference, please post a comment).
Note that I'm talking about Unix based systems here.
/etc/login
file. The expansion is traditionally done by the shell, but any language that has pretensions to be "scripting" will do this as well.
Nov 16, 2010 at 11:20
~
as a synonym for the user's home directoy.
Actually, both of the answers by Adrian Mouat and studiohack are true.
In operating systems with limited naming convention (Older version of Windows/DOS etc') it signifies a long name.
e.g. "c:\program files\" is equivalent to "c:\progra~1\"
In some operating systems (namely Unix) it means home-dir (and might be seen as an absolute but not canonical path).
e.g."/a/vol01/usr/mike/" might be shortened to "~/mike/"
* where 'usr' is the home dir.
On many file systems, a file name will contain a tilde (~) within each component of the name that is too long to comply with 8.3 naming rules.
Source: Naming Files, Paths, and Namespaces - Short vs. Long Names - MSDN
(Part-way down the page...)
192.168.1.1
or somefile.namewithdot
)
And if you do ASP.NET programming it means the top level of the website; rather than navigating using ../../images/some_image.jpg (and getting your nesting level wrong!) you can simply say ~/images/some_image.jpg
/images/some_image.jpg
should take you to the root of any web site. What additional functionality does the tilde provide in ASP.NET?
More about Windows:
If hidden file name starts with '~' then Windows Explorer process it as system hidden file. More info in Why are hidden files with a leading tilde treated as super-hidden?
If short file/directory name contains '~' (like "c:\ololoo~1") it is possible for corresponding long name of this file/directory to exceed maximum length (MAX_PATH=260). Developers should workarond this with "\\?\" prefix (even on newer Windows 10 as user can disable ">260"-long paths support with LongPathsEnabled
registry parameter or with "Enable NTFS long paths" group policy). Example for this workaround using C# can be found in ZetaLongPaths library sources.
Here is a couple of hints that can help you to figure it out better:
$ readlink -f ~
$ echo $HOME
Note: $
is a convention to specify the user command line prompt, it is not a part of the commands.