你在工作中 Linux, 使用命令 ls, 因为 终端 系统, 为 列表 内容 目录 当前或你将它作为参数传递的任何其他目录. 此命令还提供了大量的 选项 这允许您选择要显示的内容和如何去做.
在所有选项中, 我们可以选择 -d, 这将允许您列出 目录名称 而不是文件中所载. 此外, 我们有模式 */ 这将使该 只列出目录 和忽略的文件. 喜欢这个, 如果我们要在其中运行该命令的示例目录 ls 我们获得以下:
1 2 3 4 5 6 7 | $ ls -l -rw-r--r-- 1 root root 0 Jun 15 18:21 archivoA.txt -rw-r--r-- 1 root root 0 Jun 15 18:21 archivoB.txt -rw-r--r-- 1 root root 0 Jun 15 18:21 archivoC.txt drwxr-xr-x 2 root root 4096 Jun 15 18:21 directorioA drwxr-xr-x 2 root root 4096 Jun 15 18:22 directorioB drwxr-xr-x 2 root root 4096 Jun 15 18:21 directorioC |
如果 只有运行 带的模式的命令 仅显示目录, 忽略文件:
1 2 3 4 5 6 7 8 9 10 | $ ls -l */ directorioA/: total 0 directorioB/: total 0 -rw-r--r-- 1 root root 0 Jun 15 18:22 archivo1.txt directorioC/: total 0 |
我们看到,它显示了目录问题, 但此外, 它显示在这些目录中的文件. 为了避免这种, 我们要去 添加 选项 -d 到前面的命令, 所以会有:
1 2 3 4 | $ ls -ld */ drwxr-xr-x 2 root root 4096 Jun 15 18:21 directorioA/ drwxr-xr-x 2 root root 4096 Jun 15 18:22 directorioB/ drwxr-xr-x 2 root root 4096 Jun 15 18:21 directorioC/ |
以这种方式, 只有 我们就会获得 目录列表, 忽略包含的文件.
保持在头脑中的例子我们也有使用选项 -l 要显示一些更多的信息, 但此选项是可选的因为它不会干扰我们的使命.
我们的留言或输入到论坛