Linux输出“Argument list too long”的解决方法

简介: Linux输出“Argument list too long”的解决方法
  • 原因


在Linux下使用cpmvrm等命令时,经常会碰到“Argument list too long”错误,这个主要就是因为要cp、mv、rm的文件个数太多而导致的


  • 解决方法


Argument list too long这个问题的解决主要会用到两个命令,findxargs


  1. 删除aaa目录下以.zip结尾的文件


#方法一:
find /aaa/ -name "*.zip" | xargs -i rm {}
#方法二:
find /aaa/ -name "*.zip" -exec rm {} \;
  1. 复制aaa目录下以.zip结尾的文件到bbb目录
#方法一:
find /aaa/ -name  "*.zip" | xargs -i cp {} bbb
#方法二:
find /aaa/ -name  "*.zip" -exec cp {} bbb \;
  1. 移动aaa目录下以.zip结尾的文件到bbb目录


#方法一:
find /aaa/ -name  "*.zip" | xargs -i mv {} bbb
#方法二:
find /aaa/ -name  "*.zip" -exec mv {} bbb \;


解释


find aaa/ -name "*.zip"是指在aaa文件夹下查找以.zip结尾的文件。


xargs命令是给其他命令传递参数的一个过滤器,也是组合多个命令的一个工具。而-i参数会将xargs的内容赋值给{}。


-exec参数后面是指执行其后面的命令,-exec以;为结尾,由于各个系统中分号的意义不同,因此可以使用\进行转义,最终{}会被find命令的结果替换。

目录
相关文章
|
缓存 资源调度 DataWorks
DataWorks操作报错合集之DataWorks节点报错:OSError: [Errno 7] Argument list too long,该怎么处理
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
653 1
|
Java
IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App
IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App
998 0
|
分布式计算 DataWorks 监控
DataWorks操作报错合集之遇到“OSERROR: argument list too long”的错误,该如何处理
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
345 1
Intellij IDEA运行报Command line is too long的解决办法
Intellij IDEA运行报Command line is too long的解决办法
2606 1
|
Java API
将`List<String>`转换为`List<Long>`
将`List<String>`转换为`List<Long>`
1608 0
四种解决”Arg list too long”参数列表过长的办法
这些方法都可以帮助你避免因参数列表过长而导致的错误。选择方法取决于具体情况和需求。
1265 0
|
Java Spring
Command line is too long. Shorten command line for Application or also for Spring Boot default confi
Command line is too long. Shorten command line for Application or also for Spring Boot default confi
507 1
|
Java
IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App
IDEA-解决Command line is too long. Shorten command line for SpringBootMainApplication or also for App
455 0
|
Java
【异常】SpringBoot报错Command line is too long.Shorten command line for Application or also for Applicatio
【异常】SpringBoot报错Command line is too long.Shorten command line for Application or also for Applicatio
4418 0
|
安全 Java
java线程之List集合并发安全问题及解决方案
java线程之List集合并发安全问题及解决方案
2312 1

热门文章

最新文章