Linux or UNIX-like system use the ls command to list files and directories. However, ls does not have an option to list only directories. You can use combination of ls command, find command, and grep command to list directory names only. You can use the find command too.
How do you only find directories in Unix?
In this tutorial, I will show you a number of ways to list directories only in Linux.
- Listing directories using Wildcards. The simplest method is using wildcards. …
- Using -F option and grep. The -F options appends a trailing forward slash. …
- Using -l option and grep. …
- Using echo command. …
- Using printf. …
- Using find command.
How can I see my directory in Linux?
By default, the Bash prompt in Red Hat Enterprise Linux shows just your current directory, not the entire path. To determine the exact location of the current directory at a shell prompt and type the command pwd. This example shows that you are in the user sam’s directory, which is in the /home/ directory.