Originally Posted by .product
There exist ~/docs/office/report.txt
why does following command fails to get it.
~>find ./ -name report*
where as if i give the full name report.txt it works !
When an argument to a command uses a shell meta-character, like '*', you should always quote that argument to protect it from being evaluated by the shell. In this case, the shell will try to expand that argument in the current directory
, and if anything matches then the result of that expansion is what gets passed to find
. If the current directory happened to contain a file named "reporters", then the command that is actually executed would be
find ./ -name reporters
and that is not going to match a file named "report.txt".
Now if someone tries your command line when there is not
any matching file in the current directory, then the argument gets passed unaltered and find
does what was expected.
Incidentally, if the pattern happens to match more
and one name in the current directory, then all of those names will be included in the find
command, and the result is the rather confusing error message, "find: paths must precede expression: ...".