When running the script today, the following error is reported:
Find: paths must precede expression
Usage: Find [-H] [-L] [-p] [path...] [expression]
Then I checked the results online and found an article, which is probably like this:You need to add single quotation marks when searching multiple files.
I used double quotation marks all the time, and I have not encountered any problems. This time I reported an error ~
SSH $ IP "CD $ path; find.-Name'Access. $ month *. Log'-Print-exec zip-r access.w.month.zip
{}\;"
ModifySingle quotesAfter that, I will see you again and report an error ~
Example:
# Create four text files in the tmp directory # cd/tmp # touch keys, and 42.16.txt # Find.-Name *. txtfind: paths must precede expression: 2.txt
This prompt is displayed because the asterisk is expanded to all files in the current directory. Such a match will certainly fail. Now you can see:
# Echo * 1.txt 2.txt 3.txt 4.txt# echo '* # echo \**
If you want the asterisk to be unexpanded, you need to add it.Parentheses or backslash escapeAnd then we will know how to find them.
# Find. -name '*. TXT 'Find. -name '*. TXT '. /4.txt. /2.txt. /3.txt. /1.txt# or use the backslash find. -Name \*. TXT. /4.txt. /2.txt. /3.txt. /1.txt