Linux Shell Scripting Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

Directories in the current path can be displayed in the following ways:

  1. Use ls with -d to print directories:
        $ ls -d */
  1. Use ls -F with grep:
        $ ls -F | grep "/$"
  1. Use ls -l with grep:
        $ ls -l | grep "^d"
  1. Use find to print directories:
         $ find . -type d -maxdepth 1 -print