[opensuse] How to delete a symlink and the folder to which it points
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 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
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@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 05/07/12 13:29, Bernhard Voelker wrote:
On 07/05/2012 01:11 PM, lynn wrote:
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'
Thanks Berny Exactly what I wanted. L x -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (2)
-
Bernhard Voelker
-
lynn