In Unix, how do you remove everything in the current directory and below it?

前端 未结 10 1959
庸人自扰
庸人自扰 2021-01-29 21:57

I know this will delete everything in a subdirectory and below it:

rm -rf 

But how do you delete everything in the current d

10条回答
  •  执笔经年
    2021-01-29 22:22

    Will delete all files/directories below the current one.

    find -mindepth 1 -delete
    

    If you want to do the same with another directory whose name you have, you can just name that

    find  -mindepth 1 -delete
    

    If you want to remove not only the sub-directories and files of it, but also the directory itself, omit -mindepth 1. Do it without the -delete to get a list of the things that will be removed.

提交回复
热议问题