Argument list too long error for rm, cp, mv commands

前端 未结 27 2470
长情又很酷
长情又很酷 2020-11-22 04:50

I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars).

When I try to delete all PDFs together using the fol

27条回答
  •  礼貌的吻别
    2020-11-22 05:10

    You could use a bash array:

    files=(*.pdf)
    for((I=0;I<${#files[@]};I+=1000)); do
        rm -f "${files[@]:I:1000}"
    done
    

    This way it will erase in batches of 1000 files per step.

提交回复
热议问题