multiple links with single ln command

Brian O'Shea b_oshea at yahoo.com
Tue Jun 27 22:55:00 UTC 2006


Unfortunately, it is impossible with the current syntax of the
ln command.  It does allow you to specify multiple sources as
arguments though, with a final argument naming a target directory
in which to create the links to the source files.  For example:

    $ mkdir test
    $ mkdir test/a
    $ mkdir test/b
    $ mkdir test/c
    $ mkdir links
    $ cd ./links
    $ ln -s ../test/* .
    $ ls -l
    lrwxr-xr-x  1 boshea  boshea  9 Jun 27 15:50 a -> ../test/a
    lrwxr-xr-x  1 boshea  boshea  9 Jun 27 15:50 b -> ../test/b
    lrwxr-xr-x  1 boshea  boshea  9 Jun 27 15:50 c -> ../test/c

However, this is not exactly what you are trying to do in your
example; you are trying to create multiple target links with the
same name in different directories.  Unfortunately, because the ln
command's syntax allows you to specify multiple source files, it
would be ambiguous to try to make it also allow you to specify
multiple targets.

Hope that helps.
-brian

--- 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?
> 
> thanks.  sorry if this is a no-brainer,
> S
> 
>  		
> ---------------------------------
> Now you can have a huge leap forward in email: get the new Yahoo! Mail. 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the freebsd-questions mailing list