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

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

    You can create a temp folder, move all the files and sub-folders you want to keep into the temp folder then delete the old folder and rename the temp folder to the old folder try this example until you are confident to do it live:

    mkdir testit
    cd testit
    mkdir big_folder tmp_folder
    touch big_folder/file1.pdf
    touch big_folder/file2.pdf
    mv big_folder/file1,pdf tmp_folder/
    rm -r big_folder
    mv tmp_folder big_folder
    

    the rm -r big_folder will remove all files in the big_folder no matter how many. You just have to be super careful you first have all the files/folders you want to keep, in this case it was file1.pdf

提交回复
热议问题