multiple links with single ln command

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Jun 28 07:12:56 UTC 2006


On 2006-06-27 14:14, sara lidgey <slidgey at yahoo.ca> wrote:
> Hi All,
>
> I've read the man page for ln but can't find a way to do this.  I want
> to create multiple links to a single directory with one command.
> Consider the following example.  I have a directory structure like
> this:
>
> test/a/
> test/b/
> test/c/
>
> I want to create a symbolic link called "clink" in test/a/ and test/b/
> which points to test/c/
>
> The only way I know to do this is with two commands:
> ln -s test/c test/a/clink
> ln -s test/c test/b/clink
>
> Can it be done with a single command?

I don't think so.  The closest you can come to ``a single command''
would be a loop:

    $ for dirname in a b ; do ln -s test/c "test/$dirname/clink" ; done



More information about the freebsd-questions mailing list