Ubuntu 16.4

Please let me know because the behavior of the following commands is too different.
For "y" *, there is one file that starts with y, so one file is certainly searched.
If i do "y *", a large number of files containing y under the directory will be searched in a row.

$find ./ -name "y" *
$find ./ -name "y *"

I don't really understand the difference, but can anyone please tell me?

  • Answer # 1

    of the find command-nameFor the file name pattern specified in the option, specify "the file name you want find to find in the directory to be searched", isn't it?

    "y" *If you specify, the shell will replace the "filename starting with y" in the current directory when you run find, and then find will be run.
    For example, if there is a file named "yes" in the current directory, it will search for a file with the file name "yes" in the searched directory.

    Note: If you are lucky enough that no file matching "y" * exists in the current directory (because * is not expanded), the result will be"y *"Will be the same as. Also, if multiple files match, multiple filenames will be interrupted by the find argument, which may result in a syntax error or unexpected results.

    On the other hand,"y *"If you specify, "y *" is passed to find as it is and find is executed without replacement by the shell.
    Then, in the search destination directory, the file with the file name matching "y *" will be searched.

    Conclusion: with find-nameBe sure to quote when using.