1

When I type find . -name "so*" I get all these results:

./sort
./.cache/evolution/sources
./.config/evolution/sources
./.local/share/sounds 

But when I type find ./* -name "so*" I only get ./sort.

From what I know when I use . in the command I am asking to find files that begin with "so" in my current directory, but when I use ./* it displays only the ./sort file and doesn't display the hidden files, so I am wondering what adding /* actually does and how it changes my query/instruction.

1
  • 3
    Both . and ./ refer to the current directory - I think maybe your confusion is because find by default returns all files (including hidden ones) whereas the shell glob * expands only to non-hidden files by default (in bash, you can modify that behaviour using the dotglob shell option). Also find descends recursively of course. Aug 30, 2020 at 17:57

1 Answer 1

1

find . means search from the current directory.

find ./* means search from all files and directories in the current directory that are matched by a *.

However, the * is expanded by the shell, so that find thinks you really typed a command like:

find ./sort ./another-dir ./another-file ./etc -name "so*"

Your observation is correct. By default, a leading * excludes files or directories beginning with a ., so they are never even seen by find. This is not just hidden files, but also the current and parent directories, so .* usually isn't a good idea!

1
  • Why does the OP get fewer results with ./*?
    – Zanna
    Aug 30, 2020 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.