Today, when we execute find./- Mtime + 30 – type F – name. PHP on the server, we report the following error:
find: paths must precede expression: 2.txt
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Then I checked it on the Internet, and found an article, which is like this: you need to add quotation marks when searching for multiple files
find ./ -mtime +30 -type f -name '.php'
or
find ./ -mtime +30 -type f -name ".php"
In this way, no more errors will be reported after the implementation, and a small problem will be solved
##Example:
Enter the TMP directory and create four new text files
cd /tmp
touch {1,2,3,4}.txt
find . -name *.txt
find: paths must precede expression: 2.txt
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
```
This prompt appears because the asterisk is expanded to all files in the current directory, and such a match will of course result in an error. Just look at this.
```
echo *
1.txt 2.txt 3.txt 4.txt
echo '*'
*
echo \*
*
```
If you want the asterisk not to be expanded, you need to add brackets or backslash escape, know this we will know how to find
```
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
```
Similar Posts:
- Mac ADB prompts command not found
- ERROR: Functions in index expression must be marked IMMUTABLE
- [Node.js] fs.renameSync() Error: Error: ENOENT: no such file or directory, rename…
- Git LS files displays the current file status
- “Docker build” requires exactly 1 argument [How to Solve]
- [Solved] Github Action Error: Error: Unable to process file command ‘env’ successfully.
- How to Replace log4j with shell Script in Bulk
- Ora-01653: table a cannot be extended by 1024 (in table space ABC)
- Wnmp environment configuration (Windows + nginx + MySQL + PHP)
- Insufficient space for shared memory file [How to Solve]