By default when you run the ls command, it will show you all the files and directories in the directory you run this command.
If you want to only display the list of all the directories, you can make use of the -d option.
-d: Directories are listed as plain files (not searched recursively).
Note it will not work just by using the -d option, you would also need to add */
% ls -d */ /Applications /System /Volumes /cores /etc /opt /sbin /usr /Library /Users /bin /dev /home /private /tmp /var
The * is the wildcard to match any string and / to indicate that only directories should be listed.
If you also want to see hidden files you may add -a flag and -l to display it as a list.
% ls -lad */
Have Questions? Post them here!
- How to Display content of a file in Terminal Screen?
- How to Install CVS Version Control on Linux/Ubuntu
- How to install and Configure sar sysstat tools in Ubuntu Linux
- ls command to list only directories
- [Ubuntu] Search a package and versions using apt command
- zsh hello world example
- Linux Remove or Delete Files and Directories using Terminal Commands
- How to tar.gz a directory or folder Command
- Calculate days between dates using dateutils ddiff command
- How to ls command to output one entry per line [macOS/Linux/Bash]
- 3 Commands to stop Nginx Server
- Create and write file in single Linux/macOS command
- SCP Copy all files from directory to Local Folder
- How to go to the End of File in Nano Editor
- How to remove/delete a directory in Linux/macOs
- How to Copy Entire Directory to another Directory in Linux
- Execute .bin and .run file Ubuntu Linux
- The Date Command and its usage [Linux - Unix - macOS]
- Fix - ssh-copy-id no identities found error
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to Select All text in vim/vi editor using Keyboard
- Linux: Create a New User and Password and Login Example
- Command to display epoch time Terminal
- How to install curl on Alpine Linux
- How to exit from nano command
- Easy Steps to Upgrade iPhone to the new iOS 16 - HowTos
- Cannot access Windows application shortcuts on Start menu and Taskbar - Windows
- Turn Off Auto-Brightness on iPhone running iOS 16 - iOS
- How to access SharePoint Online data using Postman - REST API and Bearer token - SharePoint
- Android Disable back button programatically - Android
- [fix] JSON Expected BEGIN_OBJECT but was STRING at line 1 column 1 - Java
- bash get year 2021 calendar - Bash
- How to Configure Eclipse keymap in IntelliJ IDE - Android-Studio