cmd/ln: Difference between revisions
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
mNo edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
*** The fact that <code>ln</code> reports the first param instead of the second one seems to be a {{l/sub|bug}}. Yes, the first param is a file that does exist, but that's not the problem. | *** The fact that <code>ln</code> reports the first param instead of the second one seems to be a {{l/sub|bug}}. Yes, the first param is a file that does exist, but that's not the problem. | ||
** "<tt>'{{arg|arg 2}}': File exists</tt>" (arg 2 should be {{arg|name for link}}): You've got the arguments backwards, and are trying to create a link under the same name as the existing file (to a file which doesn't exist). | ** "<tt>'{{arg|arg 2}}': File exists</tt>" (arg 2 should be {{arg|name for link}}): You've got the arguments backwards, and are trying to create a link under the same name as the existing file (to a file which doesn't exist). | ||
===another way to think of it=== | |||
If you're in the folder '''where you want the link to go''': | |||
ln -r --symbolic {{arg|relative path}}/{{arg|name of file/folder}} ./{{arg|name for link}} | |||
If you're in the folder '''where the existing/real file is''': | |||
ln -r --symbolic ./{{arg|name of file}} {{arg|relative path}}/{{arg|name for link}} | |||
==Example== | ==Example== | ||
I pretty much always get confused as to which is the link and which is the target, so here's an example. You're inside {{fmt/code|/git/futilities/human/ff}} and you want to create a link called "lib" to the "lib" folder at {{fmt/code|/git/futilities/lib}}: | I pretty much always get confused as to which is the link and which is the target, so here's an example. You're inside {{fmt/code|/git/futilities/human/ff}} and you want to create a link called "lib" to the "lib" folder at {{fmt/code|/git/futilities/lib}}: | ||
Revision as of 17:56, 13 April 2024
ln is the Linux command for creating a link to a file or folder.
To create a relative link:
ln -r --symbolic ./Template:Arg Template:Arg
- Relative links will still work even if the folder containing both files (the original and the link) is moved or copied.
- Note that a link cannot have the same name as a folder in the same directory.
- The error message "ln: failed to create symbolic link 'Template:Arg': File exists" can be maddeningly misleading. It seems to always report the existing file, even when the problem is actually that the second filename (the link-name) already exists. Translation:
- "'Template:Arg': File exists" (arg 1 should be Template:Arg): The link-name is the same as an existing file, possibly a folder.
- The fact that
lnreports the first param instead of the second one seems to be a Template:L/sub. Yes, the first param is a file that does exist, but that's not the problem.
- The fact that
- "'Template:Arg': File exists" (arg 2 should be Template:Arg): You've got the arguments backwards, and are trying to create a link under the same name as the existing file (to a file which doesn't exist).
- "'Template:Arg': File exists" (arg 1 should be Template:Arg): The link-name is the same as an existing file, possibly a folder.
another way to think of it
If you're in the folder where you want the link to go:
ln -r --symbolic Template:Arg/Template:Arg ./Template:Arg
If you're in the folder where the existing/real file is:
ln -r --symbolic ./Template:Arg Template:Arg/Template:Arg
Example
I pretty much always get confused as to which is the link and which is the target, so here's an example. You're inside Template:Fmt/code and you want to create a link called "lib" to the "lib" folder at Template:Fmt/code:
ln -r --symbolic ../../lib/ ./lib
..or, in other words:
ln -r --symbolic Template:Arg Template:Arg
