"Illegal option" error when using find on macOS

22,994

The first argument to find is the path where it should start looking. The path . means the current directory.

find . -type f -name '*R'

You must provide at least one path, but you can actually provide as many as you want:

find ~/Documents ~/Library -type f -name '*R'
Share:
22,994
Gravity M
Author by

Gravity M

Updated on July 09, 2022

Comments

  • Gravity M
    Gravity M almost 2 years

    I am trying to list the files only with the letter "R" at the end. I used find as follows in macOS Terminal,

    find -type f -name '*R' 
    

    But I got the message saying illegal option --t.

  • Reinstate Monica Please
    Reinstate Monica Please over 9 years
    You should probably specify that you're talking about bsd find. find -type f -name '*R' is completely fine in gnu.
  • rob mayoff
    rob mayoff over 9 years
    I'm talking about standard POSIX find.
  • Reinstate Monica Please
    Reinstate Monica Please over 9 years
    Yes, but the reason for the confusion here is likely that gnu find will default to . if you don't provide an argument. Mac OS uses bsd by default, which requires an argument if you don't provide one to -f. And using statements like must provide at least one path without specifying a version of find is likely just going to cause more confusion.
  • Cole Bittel
    Cole Bittel over 8 years
    I came to this question, having the exact same confusion that @BroSlow was suggesting.