[LINUX]findコマンドを使ったらfind: paths must precede expressionとなったときの対応方法

 Get confused with find command in some way.

 When I execute the [find ./ -name ice*], I got below expression error.

    -find: paths must precede expression

Asked Mr. Google, it seems that just miss the word expression.

So the solution is to add "", double quotation for it.

Then it will work fine.


Document in Japanese:

findコマンドでファイル名を * で検索したら怒られた

  • 環境
    • RHEL 6.7
    • Bash
$ find --version
find (GNU findutils) 4.6.0
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
​
Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

$ find . -type f -iname *3*
find: paths must precede expression: 30_hoge.sql
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

理由 : "で囲んでいないから

対応方法 : "で囲む

$ find . -type f -iname "*3*"
30_hoge.sql 

コメント