bash Linux - 如何在不使用 find 的情况下删除目录中的所有文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16693772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 05:29:29  来源:igfitidea点击:

Linux -How to delete all files in a directory without using find

linuxbash

提问by tom

I am trying to delete all files in my directory "XYZ" without using find command in bash on Linux.

我试图删除我的目录“XYZ”中的所有文件,而不在 Linux 上的 bash 中使用 find 命令。

回答by Claudio

Use the following command:

使用以下命令:

rm -f XYZ/*

If you want to delete also subdirectories, use:

如果您还想删除子目录,请使用:

rm -fr XYZ/*

If you also want to delete the directory, use

如果您还想删除目录,请使用

rm -fr XYZ

回答by Harry

If you want to delete all files in a directory, go into the directory and execute: rm -f *

如果要删除某个目录下的所有文件,进入该目录执行:rm -f *

回答by meagar

Why would findeven enter into it? use rm -r XYZto recursively remove the directory XYZ.

为什么find还要进去呢?用于rm -r XYZ递归删除目录XYZ