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

简介:

今天在跑脚本的时候看到如下报错:

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

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

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

例子说明:

[html] view plain copy
  1. # 进入tmp目录新建4个文本文件  

  2. # cd /tmp  

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

  4. # find . -name *.txt  

  5. find: paths must precede expression: 2.txt  


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


[html] view plain copy
  1. # echo *  

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

  3. # echo '*'  

  4. *  

  5. # echo \*  

  6. *  



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


[html] view plain copy
  1. # find . -name '*.txt'  

  2. find . -name '*.txt'  

  3. ./4.txt  

  4. ./2.txt  

  5. ./3.txt  

  6. ./1.txt  

  7. #或者使用反斜杠  

  8. find . -name \*.txt  




     本文转自韩立伟 51CTO博客,原文链接:http://blog.51cto.com/hanchaohan/1405508,如需转载请自行联系原作者





相关文章
|
7月前
|
机器学习/深度学习 Python
【Python】已解决TypeError: init() got an unexpected keyword argument ‘threshold’
【Python】已解决TypeError: init() got an unexpected keyword argument ‘threshold’
402 0
Invalid mapping pattern detected: /download/{{fileName}} ^Not allowed to nest variable c
Invalid mapping pattern detected: /download/{{fileName}} ^Not allowed to nest variable c
|
XML 数据格式
XML问题: The processing instruction target matching "[xX][mM][lL]" is not allowed
XML问题: The processing instruction target matching "[xX][mM][lL]" is not allowed
239 0
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
error: passing ‘const AppJniCommand’ as ‘this’ argument discards qualifiers [-fpermissive]
116 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
165 0
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
解决办法: error: passing ‘const VideoFrame’ as ‘this’ argument discards qualifiers [-fpermissive]
250 0
解决办法:defined but not used [-Werror=unused-variable]
解决办法:defined but not used [-Werror=unused-variable]
842 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
find: missing argument to `-exec‘ 已解决
find: missing argument to `-exec‘ 已解决
703 0
find: missing argument to `-exec‘ 已解决
find: missing argument to `-exec'
今天使用find命令查找删除文件时,遇到下面错误,这个是因为在{}和\之间必须要有空格,否则会报上面的错。 以前都没有注意到这个细节,特此记录一下。   [root@DB-Server full]#  find  .
1465 0

热门文章

最新文章