We're an ISO27001:2013 Certified Supplier

When listing files with ls, we sometimes want to see the contents of directories, and other times we want to see the directory entry itself.

If you give a wildcard argument to ls, it will recurse one level of directory:

$ ls M*
March_report.odt May_budget.ods

Music:
Hello.flac HotelCalifornia.flac TheBends.flac

To avoid the recursion, add -d to the ls command:

$ ls -d M*
March_report.odt May_budget.ods Music

You can take that one step further and list only directories (not their contents):

$ ls */ -d
Music/

Could this Linux Tip be improved? Let us know in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Secure. Reliable. Scalable.

If that doesn't describe your current Linux systems, check out our FREE Linux Survival Guide to help you get your systems up to scratch today!

  • This field is for validation purposes and should be left unchanged.