OT: symlinks question

On Thu, May 31, 2007 at 09:01:44PM +0200, Jan Willem Stumpel wrote:
> Is there a single command to change the target of a symlink?
>
> Say I have a link which points from mylink to A, made by
>
> ln -s A mylink
>
> and I want to make the link point to B instead. I can of course do
>
> rm mylink
> ln -s B mylink
>
> but is't there a simpler way to do it? I would be amazed if there
> weren't any (this operation occurs quite often), but I could not
> find any clues in man ln.

Try:

ln -s A --force mylink

or
ln -s A -f mylink

Ken

--
Ken Irving

--

No votes yet

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

OT: symlinks question

Is there a single command to change the target of a symlink?

Say I have a link which points from mylink to A, made by

ln -s A mylink

and I want to make the link point to B instead. I can of course do

rm mylink
ln -s B mylink

but is't there a simpler way to do it? I would be amazed if there
weren't any (this operation occurs quite often), but I could not
find any clues in man ln.

Regards, Jan

--

OT: symlinks question

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 31 May 2007 21:01:44 +0200
Jan Willem Stumpel wrote:

> Is there a single command to change the target of a symlink?

Try using the -f switch on ln.

- --
Andrew J. Barr
X-Mailer: Claws Mail 2.9.1 (GTK+ 2.10.12; powerpc-unknown-linux-gnu)

"The plural of anecdote is not evidence."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGX0I3huM+Z62a52oRAl9uAKDsjEysLW2mHyWKqJ7pebmG+mF9EgCg3+LY
r9ON/7q7okXhEqrGPzaYD74=
=oo1R
-----END PGP SIGNATURE-----

OT: symlinks question

Andrew J. Barr wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thu, 31 May 2007 21:01:44 +0200
> Jan Willem Stumpel wrote:
>
>> Is there a single command to change the target of a symlink?
>
> Try using the -f switch on ln.

Thanks! I had seen the -f switch in the ln man page, but hadn't
tried it because it says

-f, --force
remove existing destination files

I somehow thought from this that the file itself would be removed
(instead of just the destination part of the link).

The text in the man page should be read as:

override the target part of an existing link,
if it points to an ordinary file

.. because, sadly, and somewhat illogically, ln -sf does *not*
override an existing target if it is a directory! So for this case
it it back to "remove old link; create new link".

Regards, Jan

--

OT: symlinks question

On Thu, May 31, 2007 at 09:01:44PM +0200, Jan Willem Stumpel wrote:
> Is there a single command to change the target of a symlink?
> Say I have a link which points from mylink to A, made by
>
> ln -s A mylink
>
> and I want to make the link point to B instead. I can of course do
>
> rm mylink
> ln -s B mylink
>
> but is't there a simpler way to do it? I would be amazed if there
> weren't any (this operation occurs quite often), but I could not
> find any clues in man ln.
>

Midnight commander lets you edit symlinks. However, I don't know how it
effects the change.

Doug.

--

OT: symlinks question

On 2007-05-31 21:01:44 +0200, Jan Willem Stumpel wrote:
> Is there a single command to change the target of a symlink?
>
> Say I have a link which points from mylink to A, made by
>
> ln -s A mylink
>
> and I want to make the link point to B instead. I can of course do
>
> rm mylink
> ln -s B mylink
>
> but is't there a simpler way to do it?

I've always used "ln -nfs B mylink". Never had any problem with this.

--
Vincent Lefèvre - Web:
100% accessible validated (X)HTML - Blog:
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

--

Syndicate content