[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ln does not work as documented
From: |
Bob Proulx |
Subject: |
Re: ln does not work as documented |
Date: |
Tue, 7 Jun 2005 11:58:08 -0600 |
User-agent: |
Mutt/1.5.9i |
William J. Bruno wrote:
> > ln -s a b .. # creates links ../a and ../b pointing to ./a and
> > ./b
> I thought pointing to ./a would be an a in the current directory.
Nope. The value is used unchanged.
> It seems that I fairly often run into situations where I wish ln had
> some additional functionality, although I can't say exactly what
> it should be. But for instance, after compiling a package yesterday
> with lots of executables, I just wanted to make links to all the
> executables and put them in my ~/bin. I decided to move them
> instead because I could do mv a b c d e f g ~/bin. To ln them, which I
> would prefer, I have to type ln longpathname/a longpathname/b ... .
> Now that I think about it, I could have defined a variable to shorten
> the path name, but there were something like 8 executables.
I would typically do a for loop on the command line in that case and
use shell variables as typing aides. In bash:
touch foo1 foo2 bar baz
cd ~/bin
for f in ~-/foo[12] ~-/{bar,baz}; do ln -s $f .; done
Of course use of ~- creates full path links and I want to avoid those
if possible or I can't access them over NFS and things like that. So
instead I would do this using shell file and directory expansion along
the way.
touch foo1 foo2 bar baz
cd ~/bin
for f in ../src/adir/foo[12] ../src/adir/{bar,baz}; do ln -s $f .; done
> Wouldn't it be nice if ln had an option to try to figure out
> the relative path from the target dir to the cwd (and could perhaps
> fall back to a hard path if necessary).
I seem to recall this being available through some perl script. But
the actual example escapes me at the moment.
Bob