Score:-1

why `ls -d .` does not list all dirs, as `ls -d */` does?

us flag

Like it says in the heading, I don't get why the "correct" usage of ls -d should add */ in order for ls to find the directories in my current dir, where adding the trivial . isn't helpful

hr flag
It's the *shell*, not `ls`, that's "finding" directories when you use `*/`
Score:1
cn flag

The -d option lists directories themselves, not their content. If you issue the command ls -d . then it will list the argument, i.e. ., a.k.a. the current directory by its own, rather than listing the contents of the argument, i.e., the files in the current directory.

. represents the current directory. */ matches all directories existing in the current directory.

Try ls -dl . for a more interesting variation of the ls -d . command.

FedKad avatar
cn flag
You can expand your answer by mentioning that the `*` character is "expanded" by the shell into a list of files or directories. Compare it with `ls "*/"`.
vanadium avatar
cn flag
@FedonKadifeli yes, I could, but I do not want to turn this into a bash course. I already indicated that it "matches...".
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.