Mailinglist Archive: opensuse (818 mails)

< Previous Next >
Re: [opensuse] How to delete a symlink and the folder to which it points
On 07/05/2012 01:11 PM, lynn wrote:
Hi
I have symlinks created with ln -s which point to real folders.
I want to delete both the folder and the symlink which points to it.

I can do it by writing a script which ls -l's the symlink and cuts out
the name of the folder but. . .

I wondered if there was a one liner to do that.
L x


readlink is your friend:

$ ln -s ../other-dir link-to-other-dir

$ ls -l
total 0
lrwxrwxrwx 1 berny users 12 Jul 5 13:24 link-to-other-dir -> ../other-dir

$ readlink link-to-other-dir
../other-dir

$ rm -rv link-to-other-dir $(readlink link-to-other-dir)
removed `link-to-other-dir'
removed directory: `../other-dir'

Have fun,
Berny
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
This Thread
Follow Ups
References