Operating System - HP-UX
1834041 Members
2347 Online
110063 Solutions
New Discussion

Remove links pointing to self

 
David Robertson_4
New Member

Remove links pointing to self

How do I remove a link pointing to it's self.
e.g.
# pwd
/
# ll optdsk
lrwxrwxrwx 1 root root 20 Nov 30 08:49 optdsk -> /optdsk

Best regards,
Dave Robertson
UNIX System Administrator
Raytheon Systems Limited
Electronic Systems Glenrothes
Queensway Industrial Estate
Glenrothes. KY7 5PY
Scotland
2 REPLIES 2

Re: Remove links pointing to self

Hmmm, perhaps I did not understand it right?!
# rm optdsk
works verry well here. No problems with cyclic links.

If it does not to it, try
# mv optdsk killme
and then
# rm killme

Regards
Mike
Anthony Goonetilleke_1
Regular Advisor

Re: Remove links pointing to self

Have a look at the output below the only reason it didnt work for me initialy
is because I used escape to complete the command line and because it is
symbolic link to the directory it adds a trailing slash on to the end. If you
simply cd and do a rm optdsk it should work.

root@Test:/ # ll optdsk/
total 0
lrwxrwxrwx 1 root sys 7 Dec 2 10:26 optdsk -> /optdsk
root@Test:/ # cd optdsk/
root@Test:/optdsk # ls
optdsk
root@Test:/optdsk # rm optdsk/
rm: optdsk/ directory
root@Test:/optdsk # rm optdsk
root@Test:/optdsk # ls -la
total 2
drwxrwxrwx 2 root sys 96 Dec 2 10:26 .
drwxr-xr-x 27 root root 1024 Dec 2 10:21 ..
root@Test:/optdsk # pwd
/optdsk