3

Running:

$find . -name *.exe

gives:

./MakeItSo_1.2.2/MakeItSo_1.2.2/MakeItSo.exe
./MakeItSo.exe

but those are not the only exe files in the directory. For example, running

$find . -name ATLTester.exe

gives:

./Debug/ATLDmoVexaTester.exe

1 Answer 1

9

It's because of shell globbing. Try:

find . -name "*.exe"

When not quoted, *.exe expands to all *.exe files in the current directory, unless there are none. It so happens you have just one such a file there, so your original command was in fact:

find . -name MakeItSo.exe

If you had no *.exe files in the current directory then shell globbing wouldn't occur, find would get *.exe argument literally and your command would work as you expected. On the other hand if you had more than one file with this extension, they all would be given as arguments to find and this would lead to syntax error.

6
  • Well spotted! I puzzled over the question for a while, before I scrolled down to your answer.
    – AFH
    Jun 9, 2017 at 20:12
  • @AFH Compare this question from few hours ago and my comment there. At first I thought like 'déjà vu?' here. Jun 9, 2017 at 20:30
  • Thanks for the reference: I'd never noticed the -delete option, so it's nice to know that I'm never too old to learn.
    – AFH
    Jun 9, 2017 at 20:35
  • But the OP also said he had ATLTester.exe in the same directory. Sep 18, 2018 at 22:43
  • 1
    @Hashim In a subdirectory. This makes a huge difference. Sep 19, 2018 at 4:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .