Score:0

tree command failing strangely with some patterns

cn flag

I have the following directory:

❯ tree -p
.
└── [drwxr-xr-x]  dir
    ├── [-rw-r--r--]  a.ml
    ├── [-rw-r--r--]  a.o
    ├── [-rw-r--r--]  b.ml
    └── [-rw-r--r--]  b.o

If I try to filter tree can't find anything:

❯ tree -p -P *.ml
zsh: no matches found: *.ml
❯ tree -p -P *ml
zsh: no matches found: *ml

And if I go in the directory dir:

❯ tree -p -P *.ml
b.ml [error opening dir]

0 directories, 0 files
❯ tree -p -P *ml
b.ml [error opening dir]

0 directories, 0 files

Am I not seeing something obvious here? Why does it fail and how can I fix it?

pLumo avatar
in flag
I guess your shell tries to interpret `*.ml`, see the error message, its not `tree` that is complaining. Put the pattern in quotes and it should work fine.
Lhooq avatar
cn flag
Oh! Thanks! My issue was the "error opening dir" that I got first and it's a tree error if I'm not mistaken. But yes, quotes work perfectly fine.
Score:4
in flag

You need to quote your pattern, otherwise it will be interpreted by the shell instead of tree.

This should work fine:

tree -p -P '*.ml'
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.