LoginSignup
27
24

More than 5 years have passed since last update.

findでアスタリスクを使うときに’’で括らなければならない理由

Posted at

foo.pdf というファイルにマッチさせたくて $ find . -name *.pdf だと

find: paths must precede expression

というエラーメッセージになる。もしくは何も表示されない事もある。

これは何でかというとディレクトリに foo.pdf, bar.pdf, hoge.pdf とあった時に

$ find . -name *.pdf とするとシェルがワイルドカードを展開してしまうため

$ find . -name foo.pdf bar.pdf hoge.pdf と等価になってしまうから。

参考

linux - "find: paths must precede expression:" How do I specify a recursive search that also finds files in the current directory? - Stack Overflow
http://stackoverflow.com/questions/6495501/find-paths-must-precede-expression-how-do-i-specify-a-recursive-search-that

27
24
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
24