Chinaunix
标题:
如何删除文件夹下的隐藏文件?
[打印本页]
作者:
borefo
时间:
2010-05-31 16:21
标题:
如何删除文件夹下的隐藏文件?
用rm *命令不管用:
:~/borefo/cpdir # ll
total 76
-rw------- 1 root root 0 2013-07-05 11:33 .bash_history
-rw-r--r-- 1 root root 1177 2013-07-05 11:33 .bashrc
-rw-r--r-- 1 root root 208 2013-07-05 11:33 .dvipsrc
-rw-r--r-- 1 root root 1637 2013-07-05 11:33 .emacs
-rw-r--r-- 1 root root 1332 2013-07-05 11:33 .exrc
-r--r--r-- 1 root root 16068 2013-07-05 11:33 .gnu-emacs
-rw-r--r-- 1 root root 861 2013-07-05 11:33 .inputrc
-rw-r--r-- 1 root root 164 2013-07-05 11:33 .kermrc
-rw-r--r-- 1 root root 6043 2013-07-05 11:33 .muttrc
-rw-r--r-- 1 root root 925 2013-07-05 11:33 .profile
-rw-r--r-- 1 root root 311 2013-07-05 11:33 .urlview
-rw-r--r-- 1 root root 7913 2013-07-05 11:33 .xcoralrc
-rw-r--r-- 1 root root 1940 2013-07-05 11:33 .xim.template
-rwxr-xr-x 1 root root 1365 2013-07-05 11:33 .xinitrc.template
-rw-r--r-- 1 root root 119 2013-07-05 11:33 .xtalkrc
:~/borefo/cpdir # rm *
rm: cannot remove `*': No such file or directory
作者:
where27
时间:
2010-05-31 16:26
rm .* 别乱删啊
作者:
lkk2003rty
时间:
2010-05-31 16:29
ls -a | awk '/^\./&&$1 != "."&&$1 != ".."' | xargs rm -rf {}
复制代码
虽然不知道兰州要干啥 但是提醒一句 有风险 需谨慎 后果自负
作者:
borefo
时间:
2010-05-31 16:32
rm .* 别乱删啊
where27 发表于 2010-05-31 16:26
为什么要加点呢?
如果这个目录下还有其他的文件,比如文件夹,如何一次性删除干净呢?
作者:
where27
时间:
2010-05-31 16:34
回复
4#
borefo
rm -rf .* *
作者:
bbgg1983
时间:
2010-05-31 16:38
ls .[^.]*|xargs rm -f
复制代码
作者:
borefo
时间:
2010-05-31 16:39
回复 borefo
rm -rf .* *
where27 发表于 2010-05-31 16:34
老表,厉害呀
我想问下,为什么要要加“.”呢,同样在cp的时候光一个*也不能把隐藏文件拷贝过来,这是为什么呢?谢谢赐教
作者:
whoiswhoz
时间:
2010-05-31 16:40
如果LZ想删除文件夹的
可以
rm -rf dir
这样快点
作者:
where27
时间:
2010-05-31 16:58
回复
7#
borefo
因为隐藏文件就是以.开头啊,cp的时候如果要拷贝所有就按照楼上帅哥的说的吧,直接拷贝文件夹
作者:
Shell_HAT
时间:
2010-05-31 17:02
回复
7#
borefo
不加点不行,星号通配符不会匹配以点开头的隐藏文件。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2