删除Linux中的非空目录-“rmdir Directory not Empty”解决方案

这个 rmdir公司 命令用于删除Linux操作系统中的目录。但是当我们试图使用rmdir命令删除指定的目录时 rmdir目录不为空 “错误。为了删除一个非空目录,我应该怎么做?我可以使用rmdir来删除包含一些文件夹或文件的目录吗?

null

简短的回答是“是的,有关于rmdir directory not emptyy”错误的解决方案,但它不是使用rmdir命令。

使用rm命令删除非空目录

rmdir和rm是类似的命令,但是rm提供了更多的特性和功能,其中rmdir只用于删除空目录或文件夹。rm命令可以使用一些选项来删除非空目录。删除非空目录最关键的选项是 -右 表示递归删除的选项。递归删除意味着删除给定的目录和子目录及其文件。还有 -f级 可以提供强制删除某些次要警告的选项。

rmdir -r -f temporary

或者-r和-f选项可以如下指定。

rmdir -rf temporary

确认后删除非空目录

默认情况下 rm-射频 “命令删除或删除给定目录及其所有内容,而不询问任何问题或确认。在某些情况下,这可能非常苛刻。通过对每个已删除的文件或目录使用确认,我们可以更安全地删除文件和文件夹。这个 -我 选项用于确认给定的目录和文件删除。

rm -rfi nmap-7.91

输出如下。我们可以看到,对于每一个删除或删除,都需要一个确认,可以提供“ y “或” “.

rm: descend into directory 'nmap-7.91'? y rm: remove regular file 'nmap-7.91/FingerPrintResults.cc'? y rm: remove regular file 'nmap-7.91/nse_openssl.cc'? y rm: remove regular file 'nmap-7.91/NmapOps.cc'? y rm: remove regular file 'nmap-7.91/TargetGroup.cc'? y rm: remove regular file 'nmap-7.91/nse_nsock.cc'? y rm: remove regular file 'nmap-7.91/portreasons.h'? y rm: remove regular file 'nmap-7.91/timing.cc'? y rm: descend into directory 'nmap-7.91/liblinear'? y rm: remove regular file 'nmap-7.91/liblinear/tron.cpp'? y rm: remove regular file 'nmap-7.91/liblinear/predict.c'? y rm: remove regular file 'nmap-7.91/liblinear/README'? y rm: remove regular file 'nmap-7.91/liblinear/train.c'? y rm: remove regular file 'nmap-7.91/liblinear/COPYRIGHT'? y rm: remove regular file 'nmap-7.91/liblinear/tron.h'? y rm: remove regular file 'nmap-7.91/liblinear/Makefile.win'? y rm: remove regular file 'nmap-7.91/liblinear/linear.cpp'? y rm: remove regular file 'nmap-7.91/liblinear/Makefile'? y rm: remove regular file 'nmap-7.91/liblinear/liblinear.vcxproj'? y rm: remove regular file 'nmap-7.91/liblinear/linear.h'? y rm: remove regular file 'nmap-7.91/liblinear/linear.def'? y rm: descend into directory 'nmap-7.91/liblinear/blas'? y

删除具有完整/绝对路径的非空目录

此外,非空目录可以作为完整路径或绝对路径提供。这是一种更安全的删除非空目录的方法,因为路径是绝对路径,不能用不同的目录指定。

rm -rf /home/ismail/nmap

以详细模式打印已删除的目录和文件

删除的非空目录也可以用 -五 选项。v选项是详细模式的缩写形式。

rm -rfv nmap-7.91

输出如下。

removed directory 'nmap-7.91/liblinear/blas' removed directory 'nmap-7.91/liblinear' removed 'nmap-7.91/nmap-protocols' removed 'nmap-7.91/nmap.h' removed 'nmap-7.91/nse_utility.h' removed 'nmap-7.91/CHANGELOG' removed 'nmap-7.91/nse_utility.cc' removed 'nmap-7.91/checklibs.sh' removed 'nmap-7.91/missing' removed 'nmap-7.91/nse_main.cc' removed 'nmap-7.91/service_scan.cc' removed 'nmap-7.91/INSTALL' removed 'nmap-7.91/NewTargets.h' removed 'nmap-7.91/.lgtm.yml' removed 'nmap-7.91/nse_fs.cc' removed 'nmap-7.91/nbase/nbase_addrset.c' removed 'nmap-7.91/nbase/CHANGELOG' removed 'nmap-7.91/nbase/nbase_ipv6.h' removed 'nmap-7.91/nbase/nbase_winunix.h' removed 'nmap-7.91/nbase/snprintf.c' removed 'nmap-7.91/nbase/nbase_str.c' removed 'nmap-7.91/nbase/nbase_winconfig.h' removed 'nmap-7.91/nbase/nbase_time.c' removed 'nmap-7.91/nbase/configure' removed 'nmap-7.91/nbase/nbase_winunix.c' removed 'nmap-7.91/nbase/nbase_rnd.c' removed 'nmap-7.91/nbase/test/nmakefile' removed 'nmap-7.91/nbase/test/test-escape_windows_command_arg.c' removed directory 'nmap-7.91/nbase/test' removed 'nmap-7.91/nbase/inet_ntop.c' removed 'nmap-7.91/nbase/configure.ac'

相关文章: Certbot SSL/TLS证书续订

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞0 分享