find: paths must precede expression(转)

简介: find: paths must precede expressionUsage: find [-H] [-L] [-P] [path...] [expression] 然后就上网查了一下,结果搜索到一篇,大概是这样说的:多文件的查找的时候需要增加单引号 而我之前一直都是用的双引号,也没有遇到问题,这次却报错了~   ssh $ip "cd $path;find .

 

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

然后就上网查了一下,结果搜索到一篇,大概是这样说的:多文件的查找的时候需要增加单引号

而我之前一直都是用的双引号,也没有遇到问题,这次却报错了~

 

ssh $ip "cd $path;find . -name 'access*log' -print -exec zip -r access.$month.zip {} \;"

修改成单引号后,木有再见报错~

例子说明:

# 进入tmp目录新建4个文本文件
# cd /tmp
# touch {1,2,3,4}.txt
# find . -name *.txt
find: paths must precede expression: 2.txt

出现这个提示是因为星号被展开为当前目录下所有的文件,这样的匹配当然会出错。看这个就知道了:

# echo *
1.txt 2.txt 3.txt 4.txt
# echo '*'
*
# echo \*
*

想要星号不被展开就需要加上括号或者反斜杠转义,知道了这些我们就知道该怎么find了

# find . -name '*.txt'
find . -name '*.txt'
./4.txt
./2.txt
./3.txt
./1.txt
#或者使用反斜杠
 find . -name \*.txt
./4.txt
./2.txt
./3.txt
./1.txt

http://blog.csdn.net/zhuying_linux/article/details/7610416





相关文章
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
“Could not find suitable distribution for Requirement.parse(‘XXXX‘)”的问题
212 0
|
索引
ES6——find()、findindex()、indexof、includes()以及some
find()、findindex()、indexof、includes()以及some
73 0
error: possibly undefined macro: LT_SYS_SYMBOL_USCORE please use m4_pattern_allow
error: possibly undefined macro: LT_SYS_SYMBOL_USCORE please use m4_pattern_allow
110 0
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
69 0
|
Python
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
401 0
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
176 0
成功解决ValueError: Number of passed names did not match number of header fields in the file
成功解决ValueError: Number of passed names did not match number of header fields in the file
成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
成功解决ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or
|
SQL Java 数据库
PreparedStatement 模糊匹配 结果却:Parameter index out of range (1 > number of parameters, which is 0)
PreparedStatement 模糊匹配 结果却:Parameter index out of range (1 > number of parameters, which is 0)
385 0
Useful code snippet to parse the key value pairs in URL
Useful code snippet to parse the key value pairs in URL
Useful code snippet to parse the key value pairs in URL