Listing only directories in Linux

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Listing only directories in Linux

Postby viking60 » 21 Jan 2015, 13:14

I use ncdu to list my folders or directories and others may have other methods.
The obvious and easiest way has never been mentioned here so I'll mention it :-D

Code: Select all

ls -d */

This will list all directories - but not the subdirectories. This can come in handy when you are in /etc.
One should never forget the (not so?) obvious.

To find all directories that end with UTF-8 you could do this:

Code: Select all

ls -d *UTF-8/

To fins all directories that start with..say...modprobe ...you can do this:

Code: Select all

ls -d modprobe*/

In /etc that could be modprobe.d and modprobe.preload.d etc
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

Return to “Tips & Tricks”