Wizard
Wizard

Reputation: 22113

`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?

Upvotes: 1

Views: 66

Answers (2)

Robert Seaman
Robert Seaman

Reputation: 2582

I always find ls -d M* is quicker and easier to write (rather than find ...) where -d does the following:

-d, --directory
    list directories themselves, not their contents

Upvotes: 1

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272657

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*'

Upvotes: 3

Related Questions