如何从Linux上的目录中删除所有内容
如何从
Linux上的当前或指定目录中删除所有内容?
几种方法: > rm -fr * 解决方法
rm -fr *.*
至少GNU rm可以正常工作,因为它有特殊的代码来排除“.”和“……” $id uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup) $cd /tmp $mkdir rmtest $cd rmtest $touch .test $ls -la total 8 drwxr-xr-x 2 nobody nogroup 4096 2009-08-19 15:37 . drwxrwxrwt 7 root root 4096 2009-08-19 15:37 .. -rw-r--r-- 1 nobody nogroup 0 2009-08-19 15:37 .test $rm -rf .* rm: cannot remove `.' or `..' rm: cannot remove `.' or `..' $ls -la total 8 drwxr-xr-x 2 nobody nogroup 4096 2009-08-19 15:37 . drwxrwxrwt 7 root root 4096 2009-08-19 15:37 .. $ http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/remove.c#n440 FreeBSD rm手册页说“尝试删除文件/,.或..是一个错误”,所以如果指定强制标志来忽略错误,它也可能在那里工作. http://www.freebsd.org/cgi/man.cgi?query=rm&apropos=0&sektion=0&manpath=FreeBSD+7.2-RELEASE&format=html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |