linux删除多文件

问题:删除多文件报错:

  #cd /home/bmc/Patrol3/Linux-2-6-x86-64-nptl/remote

  #rm -rf *

  -bash: /bin/rm: Argument list too long

原因:

  系统限制,命令getconf ARG_MAX查看当前限制

方法1:

  ls -l| awk '{ print "rm -f ",$9}'|sh

方法2:

  ls |xargs rm -r

方法3:

  find /home/bmc/Patrol3/Linux-2-6-x86-64-nptl/remote -name "*.done" |xargs rm -r

方法4:

  #!/bin/bash# 此处通过 DIR 指定待处理文件所在的目录DIR='/root/mysql' 

  #待删除目录cd $DIRfor I in `ls`do

  #读取ls结果中的各个文件名进行强制删除

  rm -f $I    done

转自:https://www.landui.com/help/show-3153.html

猜你喜欢

转载自www.cnblogs.com/leisurelyRD/p/9965794.html