[wellylug] multidot filenames

Grant McLean grant at mclean.net.nz
Wed Jun 1 12:34:15 NZST 2005


On Wed, 2005-06-01 at 02:16 +0200, Martin Bähr wrote:
> On Wed, Jun 01, 2005 at 11:36:48AM +1200, E.Chalaron wrote:
> > I need to locate filenames with multidots on my system.
> > file.ext1.ext2;
> 
> find -name "*.*.*";

It might be worth pointing out, that the original poster's problems with
find probably resulted from not putting quotes around *.*.*

If you type:

  find -name *.*.*

Then the shell will attempt to expand the *.*.* bit before invoking
find, so your results will depend on whether you have any files which
match that pattern in your current directory at the time you run the
command:

If no files match the pattern in the current directory then the shell
will pass the pattern to find unchanged and it should work.

If one file matches the pattern then the shell will replace the pattern
with the matching filename and it should still work.

But if multiple files match, the shell will replace the pattern with the
list of matching files and the result will be a command line that find
can't understand, so you'll get a delightfully uninformative error:

  find: paths must precede expression
  Usage: find [path...] [expression]

Which in English translates to "you forgot to quote your wildcards" :-)

The fact that the shell expands wildcards is great because it means all
the commands don't have to include code to do it.  Of course the
downside is that it can be a little confusing if you don't know what's
happening behind the scenes.

Cheers
Grant




More information about the wellylug mailing list