Search code examples
bashlssubdirectoryglob

`ls M*` displayes the subdirectory


I run the commands and receive results as:

    $ ls M*
    ManagerGit
    $ ls m*
    ManagerGit

The problem is that dir ManagerGit isn't on the the current directory,
Try the command:

    $ ls | grep -i 'manage'
    Manager

It's subdirectory of dir Manage

    tree -L 2
  ...
    ├── Manager
    │   └── ManagerGit
  ...

What's the mechanism behind it?


Solution

  • Because the shell expands ls M* to ls Manager - i.e. list the contents of the directory called Manager.

    ls doesn't know how to filter. I suggest you do something like this:

    find . -depth 1 -name 'M*'