2010/09/08 14:20
文章作者:Enjoy 转载请注明原文链接。
某目录下文件较多,考虑一次性全部删除。[root@hx relate]# rm * -f
rm: invalid option -- ?
Try `rm ./-昆明中国_relate.txt' to remove the file `-\300\245\303\367\326\320\271\372_relate.txt'.
Try `rm --help' for more information.
这个文件删除不掉?
rm --help看了下帮助
By default, rm does not remove directories. Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.
To remove a file whose name starts with a `-', for example `-foo',
use one of these commands:
rm -- -foo
rm ./-foo
根据提示:
[root@hx relate]# rm ./-昆明中国_relate.txt
rm: remove regular file `./-\300\245\303\367\326\320\271\372_relate.txt'? y
把这个文件删除了。
附:批量删除某目录下的空文件(0字节的文件)
find . -name "*" -type f -size 0c | xargs -n 1 rm -f
修改对应的 -size 参数,可以删除指定大小的文件,例如要删除1k大小的文件:
find . -name "*" -type f -size 1024c | xargs -n 1 rm -f
但注意不要用 -size 1k,这个得到的是占用空间1k,不是文件大小1k的
如果只要删除文件夹或者名字连接等,可以相应的改 -type 参数,具体细节见 man find。
edmond
2020/11/25 14:06
[emot]cry[/emot]
分页: 1/1
1

