Linux implementation of the find command error path has done what to do?

  

Linux when using the find command error, prompt find: paths must precede expression, which is caused by what? How to solve this error? The following small series will introduce you to the solution of the Linux implementation of the find command error path must precede expression.

execute find on the server. /-mtime +30 -type f -name *.php, the following error is reported:

find: paths must precede expression

Usage: find [-H] [-L] [-P] [path. . ] [expression]

When searching for multiple files, you need to add single quotes, always use double quotes, and multiple files should be single quotes. After modification:

find . /-mtime +30 -type f -name ‘*.php’

After this execution, there is no further error, and a minor problem is solved.

Example:

# Enter 4 new text files in the tmp directory

# cd /tmp

# touch {1,2,3,4 }.txt

# find . -name *.txt

find: paths must precede expression: 2.txt

This prompt appears because the asterisk is expanded to all files in the current directory, and such a match will of course be wrong. . Look at this and you will know:

# echo *

1.txt 2.txt 3.txt 4.txt

# echo ‘*’

*

# echo \\*

*

If you want the asterisk to be unfolded, you need to add parentheses or backslashes. If you know these, we will know Know how to find

# find . -name ‘*.txt’

find . -name ‘*.txt’

. /4.txt

. /2.txt

. /3.txt

. /1.txt

#Or use a backslash

find . -name \\*.txt

. /4.txt

. /2.txt

. /3.txt

. /1.txt

I wonder if you use the find command on the server to see the same error? This is mostly the use of double quotes when looking for multiple files. After the modification, the problem is solved.

Copyright © Windows knowledge All Rights Reserved