Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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.