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

前端 未结 27 2809
长情又很酷
长情又很酷 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:19

    If they are filenames with spaces or special characters, use:

    find -maxdepth 1 -name '*.pdf' -exec rm "{}" \;
    

    This sentence search all files in the current directory (-maxdepth 1) with extension pdf (-name '*.pdf'), and then, delete each one (-exec rm "{}").

    The expression {} replace the name of the file, and, "{}" set the filename as string, including spaces or special characters.

提交回复
热议问题