gpt4 book ai didi

linux - 参数列表太长错误 rm 命令

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:15:14 26 4
gpt4 key购买 nike

我有一个基于 Linux 的服务器,我用它来进行一些文件操作并为我的多个其他服务器提供服务。

基本上,此服务器(比如服务器 1)将来自其他服务器的输入作为 .mp3 文件并转换为其他文件格式(.wav、.txt 和 .xml),然后将请求的响应发送到其他服务器。

一段时间后,我的这个文件夹(比如/Somepath/MyInputFolder)现在有数 GB 的数据,我想删除这些数据。

我尝试了 rm -r * 命令,但它说:

Argument list too long

我也试过 rm -r *.mp3rm -r *.txt 分别删除这些文件,但它给出了同样的错误。

我也试过这个 SO question并阅读此 link .

我尝试了上述 SO 问题的解决方案,并收到错误警告。

find . -name "*.txt" -maxdepth 1 -print0 | xargs -0 rm
find: warning: you have specified the -maxdepth option after a non-option argument -name, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

我怎样才能做到这一点?

最佳答案

正如您链接的答案的评论中所述,您需要将 -maxdepth 直接放在路径之后。像这样:

find . -maxdepth 1 -name "*.txt" -print0 | xargs -0 rm

关于linux - 参数列表太长错误 rm 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21450961/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com