Ziu
Ziu

Reputation: 659

Confusion about mac find command man page

While in the find manual page, the Synopsis part says:

SYNOPSIS

 find [-H | -L | -P] [-EXdsx]
      [-f path] path ...
      [expression]

And i want to find all files whose name contains "optimizing" in the current directory, so i go with this command:

find -E -f . -iregex ".*optimizing.*"

I think this match the synopsis requirements, -E for extended regex, -f . for [-f path] part But the output says:

find: -f .: unknown primary or operator

But if i remove the -f options, and run this: find -E . -iregex ".*optimizing.*". It would run as expected.

And dose the SYNOPSIS part followed the regex grammar? That is, dose [-EXdsx] means i can use any character in -EXdsx in that part?

These really confused me, and make reading man page a really horrible thing for me.

Any help would be appreciated!

Upvotes: 0

Views: 1634

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69318

If you check the synopsis carefully

SYNOPSIS
     find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]

indicates that -f path should be followed by another path, or you can omit the -f.

The syntax is loosely based on https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form

Upvotes: 1

Related Questions