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
7

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.

| improve this answer | |
  • Well spotted! I puzzled over the question for a while, before I scrolled down to your answer. – AFH Jun 9 '17 at 20:12
  • @AFH Compare this question from few hours ago and my comment there. At first I thought like 'déjà vu?' here. – Kamil Maciorowski Jun 9 '17 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 '17 at 20:35
  • But the OP also said he had ATLTester.exe in the same directory. – Prometheus Sep 18 '18 at 22:43
  • 1
    @Hashim In a subdirectory. This makes a huge difference. – Kamil Maciorowski Sep 19 '18 at 4:10

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.