bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug in find?


From: Dale R. Worley
Subject: Re: bug in find?
Date: Mon, 27 Oct 2014 18:37:25 -0400

One way to phrase it is "Do you know how quoting works?"

If the shell sees an argument like "*.zip*" (the quotes are mine, not
part of the argument), then:

1) If expanding *.zip* finds one or more files, the shell changes the
argument into a series of arguments which are the names of the files.

2) If expanding it does *not* find any files, the shell leaves it
unchanged.  (There is a shell option to cause it to stop with an error
in this circumstance, but the default of the option is off.)

In either case, the resulting arguments are handed to the program.

Thus, when you say "ls *.c" what is really executed is "ls foo.c bar.c
baz.c", if there are three .c files.  But if there are *no* .c files,
what is executed is "ls *.c", and ls then says "There is no file named
'*.c'."  (ls doesn't actually understand wildcards, it looks for
exactly that file name and doesn't find a file with that name.)

The way to avoid this is to put '...' around your wildcards when you
want them passed just that way to the program in question.  Which is
what you almost always want to do with the -name predicate in find.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]