Saturday 14 April 2018

'find' utility does not output all files when using wildcards


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

Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...