At first I thought it was only used for your home directory but it’s not. S I thought “What is it?” “How would you describe it?”
On Fri 15 Mar 2013 07:56:01 PM CDT, ballsystemlord wrote:
At first I thought it was only used for your home directory but it’s
not. S I thought “What is it?” “How would you describe it?”
Hi
It’s the tilde ( ~ ) character.
–
Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.3 (x86_64) Kernel 3.7.10-1.1-desktop
up 16:57, 4 users, load average: 0.15, 0.18, 0.16
CPU Intel® i5 CPU M520@2.40GHz | GPU Intel® Ironlake Mobile
It is just a ~ as every other character often called Tilde.
What you mean is that in bash (and several other shells) it has a special meaning when used at the beginning of a path/filename. When it simply the first item of a path (as in ~/) it means (and is expanded by the shell as) the home directory of the user that owns the (shell) process. It is in fact a short notation for $HOME.
You can also use it in the first place of a path as ~username/ where username is of course the username of a user existing on the system. It is expanded into the home directory of that user (often: /home/username/). It is not used that often as the other one, but a system manager (as root) can thus easy refer to someones home directory.
This is from the man page of bash and more elaborate:
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.
If the tilde-prefix is a
~+', the value of the shell variable PWD replaces the tilde-prefix. If the tilde-prefix is a
~-’, the value of the shell variable OLDPWD, if it is set, is substituted. If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed by a+' or a
-’, the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs builtin invoked with the tilde-prefix as an argument. If the characters following the tilde in the tilde-prefix consist of a number without a leading+' or
-’, `+’ is assumed.
If the login name is invalid, or the tilde expansion fails, the word is unchanged.
Each variable assignment is checked for unquoted tilde-prefixes immediately following a : or the first =. In these cases, tilde expansion is also performed. Consequently, one may use file names with tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value.
It could be that other programs then shells use it in their own way. It seems that you found it somewhere where you could not quite understand if it had a special meaning there and when yes, what that meaning is. As long as you do not tell, we can barely help you to explain that.
Yes, I might have elaborated a bit more on that:shame: but you guys did fine and my question is answered.
Thus, after leaving us 5 days in uncertainty if we were able to help you, your question is answered, but you prefer to keep secret to us what the question was?
A real bonus for those who answered within the hour.
Personally I call it “squiggly!”
I just thought “Why bore them, they answered your question.”
I noticed it being used in configuration files in a game called Wesnoth. I did not know the name of the charecter ‘~’ and I was confused as to how it could be used to referance two different locations;
my home directory and the main data directory of the game. So I asked what the tilde was. You explained that the shell expands it to be the home of the user. So obviously it was not a variable (or gobal variable,) as I had previosly thought and therefore could be used by many programs without trouble.