mmrs151 mmrs151 - 4 months ago 8
Linux Question

How to remove and re-create an existing symlink in one single command?

I have a symlink for my live server called

current
and I have releases in the
releases
directory, i.e
current -> releases/2012-05-08_15-13


If I want to update the symlink of my
current
directory, I have to unlink/rm it and re ln -s it.

My question is: How can I remove the symlink and update it to the latest release in one step.

Answer

The form of ln is

ln -sf sourcefile targetlink

Try

ln -sf releases/2012-05-08_15-13 current

to remove the current and create the new link.

Comments