This is the output of ls -l
ls -l
total 53484
drwxr-xr-x 3 root root 4096 2011-02-10 05:59 ~
-rw-r--r-- 1 root root 54313810 2011-02-13 05:09 jobs.jar
-rw-r--r-- 1 root root 384035 2011-02-15 05:33 jobsLog.out
I can't do rm -rf ~
because that will remove my home directory.
What should I do? Its not a problem for me, but just an eye-sore.
rm -R ./~
That will make it look for
~
in the current folder.I've made silly mistakes with
rm
before so here are a few tips I've learnt over the years to try and keep you data safe from accidents:Use a graphical solution like Nautilus. Soft-delete it to the trash. Then when you know you haven't moved your
$HOME
into the trash (everything would have started crashing and looking funky), empty your trash.Move instead of delete. Rename the directory with
mv
, eg:Then delete it.
If in doubt, use the
-i
flag when dealing with potential fubars. It will prompt you for every file removed and should let you very quickly know if something bad is going to happen.Brilliant problem :)
You can delete the directory by escaping the tilde:
This works for all sorts of special characters.
You can simply cake the folder name into apostrophes:
Just another, a little more complex, way to do it is using inode numbers:
Pros
-xdev
: Don't descend directories on other filesystems) and you can test the search first, just in case, removing-exec rm -rf {} \;
.Cons
find .
in a directory with a lot of files and/or directories will take a lot of time, and disk reading.