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

前端 未结 10 2082
庸人自扰
庸人自扰 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:24

    I believe this answer is better:

    https://unix.stackexchange.com/questions/12593/how-to-remove-all-the-files-in-a-directory

    If your top-level directory is called images, then run rm -r images/*. This uses the shell glob operator * to run rm -r on every file or directory within images.

    basically you go up one level, and then say delete everything inside X directory. This way you are still specifying what folder should have its content deleted, which is safer than just saying 'delete everything here", while preserving the original folder, (which sometimes you want to because you aren't allowed or just don't want to modify the folder's existing permissions)

提交回复
热议问题