首页 > 系统相关 >【shell】win10的wsl子系统,删除文件报错-bash: /usr/bin/rm: Argument list too long

【shell】win10的wsl子系统,删除文件报错-bash: /usr/bin/rm: Argument list too long

时间:2023-04-16 17:55:50浏览次数:49  
标签:bin shell -- MAX 报错 arguments rm input line

1、场景

    由于测试需要删除缓存目录相关文件,但是rm -rf ./*的时候报错

 

2、处理方法

cd [需要删除的目录]
ls | xargs -n 10 rm -fr ls

参数解释:

输出所有的文件名(用空格分割) xargs就是将ls的输出,每10个为一组(以空格为分隔符),作为rm -rf的参数也就是说将所有文件名10个为一组,由rm -rf删除

# xargs --help
Usage: xargs [OPTION]... COMMAND [INITIAL-ARGS]...
Run COMMAND with arguments INITIAL-ARGS and more arguments read from input.

Mandatory and optional arguments to long options are also
mandatory or optional for the corresponding short option.
  -0, --null                   items are separated by a null, not whitespace;
                                 disables quote and backslash processing and
                                 logical EOF processing
  -a, --arg-file=FILE          read arguments from FILE, not standard input
  -d, --delimiter=CHARACTER    items in input stream are separated by CHARACTER,
                                 not by whitespace; disables quote and backslash
                                 processing and logical EOF processing
  -E END                       set logical EOF string; if END occurs as a line
                                 of input, the rest of the input is ignored
                                 (ignored if -0 or -d was specified)
  -e, --eof[=END]              equivalent to -E END if END is specified;
                                 otherwise, there is no end-of-file string
  -I R                         same as --replace=R
  -i, --replace[=R]            replace R in INITIAL-ARGS with names read
                                 from standard input; if R is unspecified,
                                 assume {}
  -L, --max-lines=MAX-LINES    use at most MAX-LINES non-blank input lines per
                                 command line
  -l[MAX-LINES]                similar to -L but defaults to at most one non-
                                 blank input line if MAX-LINES is not specified
  -n, --max-args=MAX-ARGS      use at most MAX-ARGS arguments per command line
  -o, --open-tty               Reopen stdin as /dev/tty in the child process
                                 before executing the command; useful to run an
                                 interactive application.
  -P, --max-procs=MAX-PROCS    run at most MAX-PROCS processes at a time
  -p, --interactive            prompt before running commands
      --process-slot-var=VAR   set environment variable VAR in child processes
  -r, --no-run-if-empty        if there are no arguments, then do not run COMMAND;
                                 if this option is not given, COMMAND will be
                                 run at least once
  -s, --max-chars=MAX-CHARS    limit length of command line to MAX-CHARS
      --show-limits            show limits on command-line length
  -t, --verbose                print commands before executing them
  -x, --exit                   exit if the size (see -s) is exceeded
      --help                   display this help and exit
      --version                output version information and exit

Please see also the documentation at http://www.gnu.org/software/findutils/.
You can report (and track progress on fixing) bugs in the "xargs"
program via the GNU findutils bug-reporting page at
https://savannah.gnu.org/bugs/?group=findutils or, if
you have no web access, by sending email to <[email protected]>.

 

3、结果

执行后便可以顺利执行删除动作了

 

 

参考链接:

https://blog.csdn.net/ss810540895/article/details/126698298

 

标签:bin,shell,--,MAX,报错,arguments,rm,input,line
From: https://www.cnblogs.com/fireblackman/p/17323697.html

相关文章

  • 【批处理】powershell RMDIR删除文件夹及文件报错,Remove-Item: A positional paramet
    1、场景  由于测试导致的缓存文件较多,需要删除,手动删除太慢,所以直接用命令删除 2、报错备注:没装powershell的电脑可以用的  3、处理方法cmd--%/cRMDIR/Q/SC:\Users\ADMINI~1\AppData\Local\Temp参数解释:--%,停止解析符号,告诉PowerShell停止解析其余参数,并......
  • node中使用axios时:Error: unable to verify the first certificate 报错
    参考https://www.daozhao.com/10611.html报错原因:  在使用浏览器访问时,客户端、服务器在握手阶段完成验证。当我们在node中使用axios请求时,客户端没法确认服务端的TLS证书解决方案1、局部constaxios=require('axios')consthttps=require('https')//在axios......
  • 腾讯云服务 运行Docker 命令 报错 -bash: /usr/bin/docker: Permission denied
    一、报错信息-bash:/usr/bin/docker:Permissiondenied二、解决方案网上的解决方案https://blog.csdn.net/Bingorl/article/details/123349837我试了但是无效最后究极解决方案:重置腾讯云服务重装Docker  SUCCESS!!!!!!!!!!!!!!!!!......
  • Android深入学习之LayoutInflater类和ViewBinding
    在build.gradle(Module)中添加viewBinding元素后,Android会自动给模块中的每个XML布局文件生成一个相应的Binding类,该Binding类名称为XML布局文件驼峰式大写+Binding后缀。以如下所示的activity_welcome.xml文件为例,对应的ActivityWelcomeBinding.java的源代码如下所示。<?xmlv......
  • Vulnhub之Ino靶机详细测试过程(采用完全不同方法获得Shell以及本地提权)
    Ino识别目标主机IP地址─(kali㉿kali)-[~/Vulnhub/Ino]└─$sudonetdiscover-ieth1-r192.168.56.0/24Currentlyscanning:192.168.56.0/24|ScreenView:UniqueHosts......
  • shell(一) -- 变量作用领&命令替换&位置参数
    变量作用域num=10#定义全局变量exportnum#定义全局变量为环境变量bash#进入子进程exit#退出子进程 命令替换begin_time=$(date)//系统时间赋值给begin_time参数begin_time=$(date+%s)#系统时间戳,赋值给begin_time。$()只在batchshell中有效,反引号可在多种shel......
  • java: 程序包org.springframework.web.bind.annotation不存在(已解决)
    今天在创建了一个新的SpringBoot模块后,和往常一样将文件从别的模块中复制过来,然后运行鑫模块就报错了:java:程序包org.springframework.web.bind.annotation不存在,第一反应是将文件所在的包Rebuild一下,但是这次并没有起到作用。然后就想着清除一下缓存,进行步骤:File-->Invalidat......
  • go test main包报错
    前言先提出问题,再说明原因.有如下一段代码:当执行gotest测试时,会报如下错误:main.test/var/folders/55/47pl3jxx6rg7m0r6xvn4f7wr0000gn/T/go-build2769402238/b001/_testmain.go:13:8:couldnotimportmain(cannotimport"main")FAILmain[buildfailed]......
  • 红帽认证RedHat-RHCSA shell的基本应用用户和组管理网络配置和防火墙管理笔记汇总
    shell命令概述Shell作用:命令解释器介于操作系统内核与用户之间,负责解释命令行获得命令帮助内部命令help命令的“--help”选项使用man命令阅读手册页命令行编辑的几个辅助操作Tab键:自动补齐反斜杠“\”:强制换行快捷键Ctrl+U:清空至行首快捷键Ctrl+K:清空至行尾快捷键Ctr......
  • ESP3D ESP32-C3 bulid时报错 'Serial2' was not declared in this scope
    ESP3D版本: 3.0.0-alpha3 错误原因: ESP32-C3只有两个port 解决方法一: github上最新的git已经解决了该问题,使用git获取最新版,不要下载Release的 解决方法二: 去掉Serial2serial_sevice.cpp中,  第40,41行将MAX_SERIAL的值......