10
2
rm -rf *
will remove all files and folders but not hidden ones.
rm -rf .*
will remove all hidden files and folders, but not those that are not hidden, correct?
What command should one type, in order to delete all files and folders including the hidden ones? (except . and ..); ?
1NO!
.*
will expand to all invisible entries in the current directory including..
-- which means that using.*
as an argument torm -rf
will attempt to delete the directory above the one you're currently in, and all of its contents. rm will refuse to do it, but I don't consider relying on this safe... – Gordon Davisson – 2012-05-19T15:54:21.183@Gordon Davisson: I've created a directory. I've added files to it, including hidden files. I've make that command. It has deleted all the contents inside that directory recursively, and it haven't deleted any content ABOVE that directory. Can you please clarify your comment ? – MEM – 2012-05-19T15:58:53.657
Thanks for the clarification on your comment above. Now I understand your point. Any alternative suggestion then ? – MEM – 2012-05-19T16:01:21.610
how about using
find
with the-delete
flag... – user1055604 – 2012-05-19T16:04:11.4971@GordonDavisson
rm
should print arm: "." and ".." may not be removed
message in that case – it'll not automatically remove the parent directory. – slhck – 2012-05-20T13:57:37.240@slhck: right, it's the "should" that makes me nervous. It's a bit like saying "the gun's safety should keep it from shooting my foot off when I do this..." – Gordon Davisson – 2012-05-20T17:39:59.120
@GordonDavisson Well, it does print the message on OS X, I don't know about GNU though and of course you're right. Better be safe than sorry. – slhck – 2012-05-20T17:41:00.477