![]() |
1
66450146 337 天前
xargs rm --
|
3
Ewig 337 天前
[email protected]:~/pdf_file(spider)$ ls |xargs -0 -l1 rm -f
xargs: argument line too long |
4
ptyfork 337 天前
find . -type f -depth 1 -delete
|
![]() |
5
msg7086 337 天前
第一个问题。
星号展开过长。你可以一次只删一部分文件。比如像 rm 2018* 这样只删除少量文件。 第二个问题。 文件名开始的减号会被识别成参数,需要像一楼说的那样 xargs rm 后面加上 -- 把参数终结掉。 |
6
Ewig 337 天前
@msg7086 ls |xargs rm --
rm: cannot remove ‘ Value ’: No such file or directory rm: cannot remove ‘ as ’: No such file or directory rm: cannot remove ‘ Revenue ’: No such file or directory rm: cannot remove ‘ Declines-17 页.pdf ’: No such file or directory rm: cannot remove ‘ A ’: No such file or directory rm: cannot remove ‘ Wright ’: No such file or directory |
8
zealot0630 337 天前
rm "./文件名"
|
9
zealot0630 337 天前
引号不能省略
|
10
Ewig 337 天前
@zealot0630 具体格式怎么写
|
![]() |
11
lcdtyph 337 天前 via iPhone
find . -type f -delete
|
12
leido 337 天前 via Android
ls | xargs -i rm -rf {}
再不行就 find 来删 |
![]() |
13
geelaw 337 天前
一个简单的答案是直接删除 parent directory。
论 shell globbing 的坏处。 |
![]() |
14
congeec 337 天前
标题误导人,不是删除大文件报错,是文件名不符合 Linux 命名惯例导致 rm 没法正确识别文件名
|
![]() |
15
yanaraika 337 天前
不要 ls 再 pipe,find . -type f -max-depth 1 -delete 是正确的
|
16
runAll 337 天前 via iPhone
用 rsync,拿一个空目录和需要删除清空目录同步
rsync --delete-before -a -H -v --progress --stats 空目录 待清空目录 |
17
luanluan 337 天前
@leido
@zealot0630 @zealot0630 @66450146 web 目录下产生 100 多 G 的 core12121 到 core53341 ,有什么办法删除? find /web/ -name 'core*' | xargs rm -rf 安全不? |
![]() |
20
yulgang 337 天前
cd 到目标目录,cd 到目标目录,cd 到目标目录
#rm 列过长处理: find . -name "*" | xargs rm -rf '*' |
21
ptyfork 337 天前
@Ewig
depth 表示遍历的深度,如果当前的目录下有子目录,子目录中还有子目录,那么 -depth 1 表示,只删除第一层的 用 find 了就别再用管道又 xargs 了, 现在的 linux 系统 find 本身就支持 delete 参数,好用又清晰, 除非你在用上古时期的 linux |
![]() |
22
RainySeason 337 天前 ♥ 1
好巧,前两天刚看过王垠写的 unix 的缺陷
http://blog.jobbole.com/25792/ |
24
Ewig 337 天前
[email protected]:~/pdf_file(spider)$ find . -name "*" | xargs rm -f '*'
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option rm: invalid option -- '5' Try 'rm --help' for more information. |
26
hongyexiaoqing 337 天前
新建一个空的文件夹 kong,然后执行 sudo rsync -r --delete kong/ {目标路径}
|
![]() |
29
yulgang 337 天前 ♥ 1
|
![]() |
30
yulgang 337 天前
末尾打错,改成
find . -inum 上面列出的数字 -exec rm -i {} \; 按提示确认删除即可 |
![]() |
31
sunnyadamm 337 天前
@luanluan 在 web 目录执行 find . -name 'core*' -exec rm {} \;
|
32
cyspy 337 天前
GNU 这套东西的设计是真的有些问题
|
33
luanluan 337 天前
@cyspy
@sunnyadamm @yulgang @yulgang 我在 linux 里 一个目录下有好几种文件, 我想查一个文件的总大小,怎么查啊? du -sh *2018* 直接就列出来了,怎么汇总大小呢 |
34
zou2699 337 天前 via iPhone
使用 tab 补全会自动处理转义文件名的吧,直接就可以删除了吧。
|
![]() |
35
des 337 天前 via Android
@RainySeason
照理说,powershell 就是一个好设计了 |
![]() |
36
no1xsyzy 337 天前
@des 本来应该是这样的,而且还有 Smalltalk 的一些感觉……
"whatever,it might be,a line,from,csv" -split "," 还有代码块,可以改变一段代码的变量绑定 但是 PowerShell 的 REPL 实在是太垃圾了,尤其 print 出来的东西经常没有意义,另外就是隐式强类型…… 对于类型的反射求解机制也并不好( Python: dir, __dict__, hasattr ...) 文档散乱 |
![]() |
38
sunnyadamm 337 天前 ♥ 1
嗤嗤嗤,,,不多说了,block 了
|
40
maxio 336 天前
xargs -n 1
|
![]() |
41
zjsxwc 336 天前
直接删掉当前目录好了
rm -rf . ./* 的话文件一多就删不掉,报参数太长 |
42
lieh222 336 天前
在当前目录执行,for i in `ls`;do rm $i; done,这样可能比较慢,不着急可以这样删,看楼主还能发帖问明显是不着急
|
![]() |
44
rootit 336 天前
因为有特殊字符
使用 rm -f *要删除的文件 用*(正则)替代特殊字符 试试 记得要匹配到一个 小心删除其他的,先 ls *要删除的文件 看下是否匹配正确 然后再删除 |
![]() |
45
ofblyt 280 天前
这个帖子实在太危险了,看了这一贴,实操了几个命令,现在我在搜如何恢复删除文件
|