“find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?

前端 未结 6 1844
谎友^
谎友^ 2020-11-28 01:49

I am having a hard time getting find to look for matches in the current directory as well as its subdirectories.

When I run find *test.c

6条回答
  •  情歌与酒
    2020-11-28 02:29

    Try putting it in quotes -- you're running into the shell's wildcard expansion, so what you're acually passing to find will look like:

    find . -name bobtest.c cattest.c snowtest.c
    

    ...causing the syntax error. So try this instead:

    find . -name '*test.c'
    

    Note the single quotes around your file expression -- these will stop the shell (bash) expanding your wildcards.

提交回复
热议问题