Hi Eric, thanks for the quick response and clarification. I wasn't completely clear what -d was supposed to do exactly. The man pages define ls -d as: *"list directory entries instead of contents".* The files in the target directory are contents of that directory, but they get listed anyway! I still think ls -d is not accurate. Here are some examples: % \ls -d f1 f1 (but f1 is not a "directory entry" so this output is not consistent with the definition above.) If: % \ls /tmp/mydir d1/ d2/ f1 f2 % \ls -d . . (but where are the rest of the directories?) % \ls -d /tmp/mydir /tmp/mydir (Same thing, no listing of directory entries in that directory as the definition says) The behavior I'm seeing is: list directory entries instead of contents, *but not including the parent directory (or the directory specified as argument)*. I guess that's where the confusion is. IMHO, the directory that the user specifies should be the first to follow the rule, because that's what the user is concerned about the most. % \ls -d * can be accomplished by a simple: % \ls % \ls -d wrote: > tag 21218 notabug > thanks > > On 08/07/2015 06:01 PM, Sneeh, Eddie wrote: > > Hi, > > I believe there is a problem with ls -d (unless the intent is to just > list > > 1 directory). > > Thanks for the report. However, I think you have misunderstood the > purpose of -d. Try this for comparison: > > touch file > ls . file > ls -d . file > > All -d does is to list command line arguments that are directories as > the name of the directory itself, rather than descending and showing the > directory's contents. > > > Say I have a dir mydir, it has directories d1 and d2, and files f1 and > f2. > > I want to list only d1 and d2. How do I do that? I tried ls -d but that > > doesn't seem to work: > > \ls -d mydir > > returns: mydir > > \ls -d mydir/* > > returns: mydir/d1 mydir/d2 mydir/f1 mydir/f2 > > but f1 and f2 are files. > > If you want to list ONLY directories, use a glob that guarantees only > directories can be matched: > > ls -d mydir/*/ > > The trailing slash can only match directories, and will therefore skip > ordinary files. Or, you can use find: > > find mydir -mindepth 1 -maxdepth 2 -type d > > I'm closing this as not a bug as ls is working as designed, but feel > free to ask further questions. > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > > -- Best Regards, *Eddie Sneeh*