1 linux
我有一个直接调用的 /cache,它有大约一百万个文件。
我重组了我的缓存系统,将缓存文件放入 /cache 目录内的不同文件夹中。新的缓存文件已经写入这些子文件夹。所以我想删除 /cache 目录中不在任何子文件夹中的所有文件。
我将如何在 SSH 中执行此操作?
您可以使用find
命令执行此操作。
find /cache -maxdepth 1 -type f -exec rm -rf {} \;
Run Code Online (Sandbox Code Playgroud)
我建议find
在结合执行之前查看将被删除的文件列表-exec rm
:
find /cache -maxdepth 1 -type f
Run Code Online (Sandbox Code Playgroud)
这将为您提供文件列表而不删除它们。再次; 使用find
结合-exec rm
谨慎,我不能足够清晰的:)。