-
linux删除目录命令_如何使用一个Linux命令删除多个子目录
2020-09-09 15:57:37linux删除目录命令If you want to remove several subdirectories within another directory using the command line in Linux, generally you have to use the rm command several times. However, there is a ...linux删除目录命令
If you want to remove several subdirectories within another directory using the command line in Linux, generally you have to use the
rm
command several times. However, there is a faster way to do this.如果要在Linux中使用命令行删除另一个目录中的多个子目录,通常必须多次使用
rm
命令。 但是,有一种更快的方法可以做到这一点。Let’s say we have a directory called htg with five subdirectories within it and we want to delete three of them. In a normal situation, we’d use the
rm
command three times.假设我们有一个名为htg的目录,其中包含五个子目录,我们想删除其中的三个。 在正常情况下,我们将使用
rm
命令3次。However, we can make this process even shorter by combining the three
rm
commands into one. Here’s how.但是,通过将三个
rm
命令组合为一个,我们可以使此过程变得更短。 这是如何做。To remove the three subdirectories you only need to type the following command at the prompt and press Enter (obviously, change the directory names to what you want to remove).
要删除这三个子目录,只需在提示符下键入以下命令,然后按Enter键(显然,将目录名更改为要删除的目录名)。
rm -r ~/Documents/htg/{done,ideas,notes}
The words in the brackets are part of the “brace expansion list”. Each of the items in the brace expansion list is appended separately to the preceding path (~/Documents/htg/). For example, the above command is expanded into ~/Documents/htg/done, ~/Documents/htg/ideas, and ~/Documents/htg/notes, the three subdirectories under the htg directory that we want to remove. As you can see in the screenshot below, those three subdirectories were removed.
方括号中的词是“括号扩展列表”的一部分。 大括号扩展列表中的每个项目都分别附加到前面的路径(〜/ Documents / htg /)。 例如,以上命令被扩展为〜/ Documents / htg / done,〜/ Documents / htg / ideas和〜/ Documents / htg / notes,这是我们要删除的htg目录下的三个子目录。 如下面的屏幕快照所示,这三个子目录已被删除。
The
-r
flag is required when using the rm command to remove a directory rather than a file. If you leave the-r
flag out of the above command, you will get an error saying that the directories cannot be removed.使用rm命令除去目录而不是文件时,需要
-r
标志。 如果将-r
标志保留在上述命令之外,则会收到一条错误消息,指出无法删除目录。If all of the subdirectories you want to remove are empty, you can use the
rmdir
command, as shown below.如果要删除的所有子目录都为空,则可以使用
rmdir
命令,如下所示。rmdir ~/Documents/htg/{done,ideas,notes}
If it turns out that any of the subdirectories are not empty, an error will display saying that the removal failed and the subdirectory in question and its subdirectories are not removed. However, any empty subdirectories are removed.
如果事实证明子目录中的任何一个都不为空,则会显示一条错误消息,指出删除失败,并且该子目录及其子目录未删除。 但是,任何空的子目录都将被删除。
Be very careful with the
rm
command. Using it the wrong way can delete all the files on your hard drive.rm
命令要非常小心。 以错误的方式使用它可能会删除硬盘驱动器上的所有文件。You can also create a directory containing several subdirectories, or a directory tree, using one command.
您还可以使用一个命令创建包含多个子目录的目录或目录树 。
翻译自: https://www.howtogeek.com/276516/how-to-remove-multiple-subdirectories-with-one-linux-command/
linux删除目录命令
-
Linux删除目录的命令
2010-08-17 13:28:00 -
(Linux命令)删除目录
2021-02-27 13:17:36featurize图形化界面删除文件夹时,如果文件夹里面有内容,则删除失败,那么就要先删除文件夹内容再删除文件夹,这样比较麻烦,我决定采用Linux命令进行删除。 命令 删除根目录下的test文件夹 rm -rf /test ... -
linux 删除目录的命令
2015-01-05 14:15:48linux删除目录很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中。 2. 现在使用rm -rf命令即可。 rm -rf 目录名字 -r 就是(recursion)向下递归,不管有多少级目录,一并删除 -f 就是直接强行删除,不...1.linux删除目录如果目录为空,用rmdir。2.目录不为空时使用rm -rf命令即可。
rm -rf 目录名字
-r 就是(recursion)向下递归,不管有多少级目录,一并删除-f 就是直接强行删除,不作任何提示的意思 -
linux命令 删除目录
2010-04-30 11:13:00mkdir 目录名:创建一个目录 rmdir 目录名:删除目录,这个命令运用的条件是该目录为空,当非空的时候它就没作用了 所以当删除一个非空目录时: rm –rf 目录名 选项 –r 表示递归删除,即删除目录的同时,会删除其... -
linux删除目录的命令
2011-05-26 11:49:00linux删除目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中…… 直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字 -r 就是向下递归,不管有多少级目录,一并... -
Linux环境和基本命令——删除目录命令
2020-10-15 22:07:15删除目录命令 常用方法:rmdir [options] directories 常用参数(options): -p:删除指定目录后,若该目录的上层目录已变成空目录,则将其一并删除 例如: 删除目录/test/test1后,若test已变成空目录,则将其... -
【每天一个Linux命令】22. 删除文件命令rm && 删除空目录命令rmdir
2013-10-10 19:32:50用来删除文件或目录的命令 命令格式 rm命令的一般形式为: rm [选项] 文件… 该命令的各选项含义如下: - f 忽略不存在的文件,从不给出提示。 - r 指示rm将参数中列出的全部目录和子目录均递归地删除。 - i 进行... -
Linux下的目录及其操作命令(创建和删除目录的命令
2016-10-07 21:15:091.mkdir命令 该命令用来创建目录 1)一般格式 mkdir [选项] dirname 2)说明 ...该命令创建由dirname命名的目录。如果在目录名前面没有加任何路径名,...该命令用来删除空的子目录 1)一般格式 rmdir -
LINUX UNIX 删除目录的命令
2010-06-10 10:40:00在unix 或者linux删除目录的时候, 使用rmdir,如果在目录下面有一些其他文件,会很难办。 因此可以使用 rm-rf 来解决这个问题。 -r 向下递归,不管有多少级目录,删除到最深。 -f 强行删除,... -
Linux命令--rmdir命令:删除空目录
2019-02-15 15:51:043.5 rmdir命令:删除空目录 既然有建立目录的命令,就一定会有刪除目录的命令 rmdir,其基本信息如下: 命令名称:rmdir。 英文原意:remove empty directories。 所在路径:/bin/rmdir。 执行权限:所有... -
Linux下的目录及其操作命令(二、创建和删除目录的命令)
2016-10-05 23:08:551.mkdir命令该命令用来创建目录 1)一般格式 mkdir [选项] dirname 2)说明 该命令创建由dirname命名的...-p 一次可建立多个目录2.rmdir命令该命令用来删除空的子目录 1)一般格式 rmdir [选项] dirname 2)说明 -
Linux命令博客目录
2018-10-05 16:05:00Linux命令(四)删除文件 rm Linux终端常用快捷键 Linux命令(五)创建文件或修改文件时间 touch Linux命令(六) 查看文件 cat tac more less tail Linux命令(七)查找文件或目录 find Linux... -
(P3)Linux基本命令:ls命令 ,linux目录操作命令 ,Linux文件操作命令
2020-09-06 17:59:22文章目录1.ls命令2.linux目录操作命令3.Linux文件操作命令 1.ls命令 总结 eg (1)显示某目录下所有的文件及子目录的详细信息 ls -lR /test (2)显示当前目录下所有文件详细信息 ls -l 2.linux目录操作命令 ... -
Linux命令常见错误处理 rm无法删除目录
2019-07-05 14:25:18rm无法删除目录 删除目录时,需添加 -r 递归删除,这样就不会报错了哦 -
linux文件移出目录命令_linux下如何删除整个文件夹及目录命令
2021-01-13 02:16:44若删除时出现 Permission denied 的提示,可以在命令前加sudo 即:sudo rm -rf 文件夹的名字,即可删除。提醒:使用这个rm -rf的时候一定要格外小心,linux没有回收站的。rm还有更多的其他参数和用法,具体参数用法... -
linux中删除文件和目录的命令 rm命令
2018-01-10 20:55:58linux中删除文件和目录的命令: rm命令。rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除。对于链接文件,只是删除了链接,原有文件均... -
linux下删除非空目录命令
2011-12-28 20:10:17例如删除当前目录下的非空目录 demo ,命令 rmdir demo 无法删除非空的目录. 应该使用命令 rm -rf 目录名 即如下命令: rm -rf demo 其中参数-f 表示force .使用了这个参数就不会提示你... -
Linux基础命令详解(Linux命令基础+Linux命令帮助+目录与文件基本操作)
2020-06-10 19:22:56文章目录前言一、Linux命令基础1.1shell1.2Linux命令的分类1.3Linux命令行的格式1.4编辑Linux命令行的辅助操作二、Linux命令帮助2.1help2.2man三、Linux目录与文件基本操作3.1切换工作目录-cd3.2查看当前工作目录-... -
linux命令(4)删除目录rm
2019-01-15 15:31:31-r 就是向下递归,不管有多少级目录,一并删除 -f 就是直接强行删除,不作任何提示的意思 举例: 删除文件夹实例:rm -rf /var/log/httpd/access 将会删除/var/log/httpd/access目录以及其下所有文件、文件夹 ... -
linux基础命令----8.创建,删除文件及目录命令
2020-05-20 21:21:26能够使用Linux命令创建文件夹 1. 创建、删除文件及目录命令的使用 touch命令效果图: mkdir命令效果图: rm命令效果图: rm删除目录效果图: 说明: rm命令想要删除目录需要加上-r选项,-r表示递归删除目录及其内容... -
Linux 命令之 mkdir 创建目录!rmdir 删除目录!(两个都为 外部命令)
2020-04-09 16:50:45请您看这里: 此链接 通往 Linux 命令大全手册,点一下吃不了亏,上不了当!说不定还会 涨知识: ... Linux 文件、目录、文本处理 命令! m... -
Linux删除目录非空的文件夹命令
2018-10-24 16:55:47linux删除目录可以用rmdir,但是当目录非空时,就不可以用这个命令了。此时使用直接rm -rf 即可: rm -rf 目录名字 其中: -r 就是向下递归,不管有多少级目录,一并删除 -f 就是直接强行删除,不作任何提示.... -
Linux命令(十三) 建立目录 mkdir 删除目录 rmdir
2018-01-17 22:36:00mkdir 命令用于创建指定的目录。创建目录时当前用户对需要操作的目录有读取权限。如果目录已经存在,会提示报错并推出。 mkdir 可以创建多级目录。 常用参数说明 -m 设置新目录的存取权限,类似于 chmod -p 该... -
Linux 创建和删除文件及目录命令
2020-08-31 06:03:33删除文件及目录命令 命令 说明 touch 文件名 新建指定文件 mkdir 目录名 新建目录(文件夹) rm 文件名或目录名 ...注意: 如果用rm命令删除目录,需要加上-r,-r表示递归删除目录及其内容 ...