linux - 关于 "ls",我怎样才能只显示目录(链接目录和隐藏目录除外)

标签 linux shell unix

我遇到了一些关于“ls”这个命令的问题

我只想打印没有隐藏或链接的目录

但是我用man ls看解释,没找到

如果有一个标志表明我可以做我想做的事......

谢谢

下面是我要解决的问题...

4. 显示可见的导出

This is two commands: The first command prints "Visible exits: "
-> It must not advance the cursor to the next line.
The second command displays the visible exits and then a period (.).
-> To prevent the linked directories contents from also displaying, you 
will need a flag.
-> Several wildcard patterns will be needed.
-> The period will be the last of these patterns.
   The period means the current directory. But here it will seem, to
   the user, to be a period at the end of a sentence listing visible
   exits.
-> You will need to use a flag to keep the output from being
   sorted (otherwise the period will not stay at the end).
-> With several patterns to search, some may have no matches. That
   is OK, but we don't want to see warning messages. Redirect these.

最佳答案

使用 ls -d */*/ 是一个通配符,它​​扩展到当前目录中的所有目录(目录以 / 结尾)。 -d 告诉 ls 列出作为参数给出的目录名称,而不是它们的内容。

关于linux - 关于 "ls",我怎样才能只显示目录(链接目录和隐藏目录除外),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29264653/

相关文章:

c - 我怎样才能等到指定的 "xterm"完成?

linux - 编写Shell脚本以安装cron作业

python - Python 代码中 STDIN 和 Fileinput 的通用构造

bash - 如何在 bash 中找到所有不以给定前缀开头的文件?

c - C套接字中需要多个连接

linux - tar: 无法创建目录 'sqljdbc_7.2/' : 权限被拒绝 tar: 无法打开 'sqljdbc_7.2/' : 是一个目录

java - 为较低的 sdk/jdk 重建项目。失败 [INSTALL_FAILED_OLDER_SDK]

linux - 如何使用 755/644 和 apache 进行 sftp 上传和 git 推送 :apache rights/owner?

python - Virtualenv 使用了错误的 python,即使它位于 $PATH 中的第一个

linux - 使用 grep 和 sed 查找和替换字符串