1. Find empty directories in the current directory using find -empty: $ find . -type d -empty 2. Use the following command to remove all empty directories under the current directory: $ find . -type d -empty -exec rmdir {} \; 3. Find empty files in the current directory using find...
find ~/Documents -type f -empty -delete Similarly, to find and delete empty directories: find /path/to/directory -type d -empty -delete -type d: Searches for directories. Example: The following command will find and delete all empty directories in theDownloadsdirectory. find ~/Downloads -t...
4. 为 find 命令指定特殊的 action(此处 -delete 表示删除搜索结果) 代码语言:javascript 代码运行次数:0 复制 Cloud Studio代码运行 $ find directory-name file2-delete$ find directory directory directory/sub-dir1 directory/sub-dir1/file3 directory/sub-dir1/file1 directory/sub-dir2 directory/sub-dir2...
和 mkdir 命令(创建空目录)恰好相反,rmdir(remove empty directories 的缩写)命令用于删除空目录,此命令的基本格式为:[root@localhost ~]# rmdir [-p] 目录名 -p 选项用于递归删除空目录。【例 1】[root@localhost ~]#rmdir cangls 就这么简单,命令后面加目录名称即可,但命令执行成功与否,取...
为find 命令指定 expression 以筛选出特定的文件 $finddirectory -name file2 directory/sub-dir1/file2 directory/file2 directory/sub-dir2/file2 为find 命令指定特殊的 action(此处-delete表示删除搜索结果) $finddirectory -name file2 -delete $finddirectory ...
Linux find命令 Linux find命令是命令行上非常有用和方便的搜索文件的命令。它可用于根据各种搜索标准查找文件,如权限,用户所有权,修改时间/日期,大小等。在这篇文章中,我们将学习使用find命令以及它支持的各种选项。 大多数Linux发行版find命令默认是可用的,因此你不
rmdir – remove empty directories, 删除空目录,非空则无法删除 语法:rmdir [OPTION]… DIRECTORY… 常用选项: 选项| 含义 —— | —— -p | 递归删除,当删除完基名目录时,如果其父目录也为空,则一并删除;依此类推,直到非空目录为止 -v | 显示命令执行的详细结果,通常与-p一同使用 ...
# find -maxdepth 2 -name passwd ./etc/passwd 1. 2. 在root目录下及其最大两层深度的子目录中查找passwd文件. (例如 root — level 1, and two sub-directories — level 2 and 3 ) # find / -maxdepth 3 -name passwd ./usr/bin/passwd ...
1.2、find命令的常用选项及实例 -name 按照文件名查找文件。 find /dir -name filename 在/dir目录及其子目录下面查找名字为filename的文件 find . -name "*.c" 在当前目录及其子目录(用“.”表示)中查找任何扩展名为“c”的文件 -perm 按照文件权限来查找文件。
find /home/sara/Documents -name "file1.txt" -delete The command has no output. Find Empty Files and Directories Use thefindcommand to search for empty files and directories on your system. The-emptyoption is used to locate files and directories that have no content. For example, search for...