I would like to create a symlink to ~/foo/ but when I write that, ~ is always resolved to the absolute home path. I've used ../s in the past and they work fine, is ~ not allowed?The reason I'd like to do that is because ~ has a different absolute path depending on the machine and Linux/OSX, but always points to my home directory.I'd like to include such a link in a git repo sync'd across several machines.
Using ~ in symlink target or making a symlink with a variable
environment variables;symlink;home
The tilde character is expanded by the shell before the command is executed. It will be replaced by the value of $HOME. So the ln utility which creates the symlink will never see the tilde, only the full path. This path will be stored in the symlink.In Linux, there is no otion to make a symlink variable. They are handled by the kernel. The kernel does not honor environment variables.BSD allows such links. They are called variant symbolic links. You can do something like this:$ ln -s ${variable} linkname$ ls -l linknamelrwxrwxrwx 1 root root 6 Sep 29 12:33 linkname -> ${variable}With varsym those variables can then be set:varsym variable=value cat linkname[...] contents of file with name value [...]