Understanding the usage of ln

ln

From coreutils' manual, for ln

ln makes links between files. By default, it makes hard links; with
the -s option, it makes symbolic (or soft) links. Synopses:

ln [option]... [-T] target linkname
ln [option]... target
ln [option]... target... directory
ln [option]... -t directory target...

• If two file names are given, ln creates a link to the first file
from the second.

• If one target is given, ln creates a link to that file in the
current directory.

If the –target-directory (-t) option is given, or failing that if
the last file is a directory and the –no-target-directory (-T) option
is not given, ln creates a link to each target file in the specified
directory, using the targets’ names.

What does the part in bold mean?

in particular
what do the followings mean

  • "failing that if the last file is a directory"
  • "using the targets’ names"?

Thanks.

Best Answer

It means that if you to ln /path/to/files/* /path/to/some/directory/ or ln -t /path/to/some/directory/ /path/to/files/*, a link to each of the files matching /path/to/files/* will be created in /path/to/some/directory/ with identical names to the originals.

Related Question