Question about the find command

find. \ (-name "_ *" -or -newer while2 \) -type f -print

In the linux command above, why should _ * be specified?

+3
source share
3 answers

First, the shell expands all unspecified * to match the names of files in the local directory.

After that, the shell runs a command findwith this list of file names.

Typically, you do not want the shell to perform "*" globing in the local directory. Typically, you wrap the find command to match file names in other directories.

The shell has several other things that it does before running the command. $ VARIABLE replaces one of them.

+9

_ * ?

, * . , , .

+5

if you do not quote it, the shell (bash?) will try to expand. if there is a file in the current directory starting with ` _`, you will get something like:

find . \(-name _somefile _someother _file3 .... -or -newer while2 \) -type f -print

Of course, not what you want. I always quote patterns, just to make sure the shell won't contact them

+2
source

Source: https://habr.com/ru/post/1704767/


All Articles