find . \( -name "_*" -or -newer while2 \) -type f -print
In the linux command above , why _* should be quoted ?
find . \( -name "_*" -or -newer while2 \) -type f -print
In the linux command above , why _* should be quoted ?
Why _* should be quoted ?
If it isn't, your shell might expand the *
to be substituted with files in the current directory. That's probably not what you wanted here.
First, the shell expands all unquoted *'s to match file names in the local directory.
After that, the shell runs the find
command with that list of file names.
Generally, you don't want the shell to do '*' globbing in the local directory. Generally, you wind the find command to do filename matching in other directories.
The shell has several other things it does before running a command. $VARIABLE replacement is one of those.
if you don't quote it, the shell (bash?) would try to expand. if there's any file that starts with '_
' on the current directory, you'd get something like:
find . \(-name _somefile _someother _file3 .... -or -newer while2 \) -type f -print
certainly not what you want. i always quote patterns, just to be sure the shell won't mess with them
A similar question: http://stackoverflow.com/questions/18836/why-doesnt-find-find-anything