Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I accidently made a link and can't delete that:

big:~# ls -al
total 88
lrwxrwxrwx  1 root root    27 May 28 18:10   -> /etc/apache2/ssl/apache.pem
drwx------  8 root root  4096 May 29 01:45 .
drwxr-xr-x 23 root root  4096 May 27 04:50 ..
drwxr-xr-x  2 root root  4096 Apr 18 19:26 backup_big

I don't wonna do experiments with "rm" :-D

share|improve this question
Slightly dangerous, but you can always just do rm -i *. The -i puts rm into confirm mode. Simply answer no to everything except the file you actually want to get rid of. – Zoredache May 29 '13 at 1:24
up vote 2 down vote accepted

In bash you can do this:

shopt -s extglob
for file in !(testfile); do echo "x${file}x"; done

and replace echo by rm (and delete the x) when you are convinced that it works.

If this is GNU:

ls -l --quoting-style= # with shell/c/escape whatever fits your need best

Or with find:

find . -type l -exec ls -l {} \;

and replace -exec ... with -delete (or the ls -l with rm).

Or you rename it (mv instead of rm) in one of these ways and delete is manually afterwards.

share|improve this answer
find . -type l -exec rm {} \; did a quite good job. ty! – DanFromGermany May 29 '13 at 0:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.