14

I have inherited a script as part of a build process for an application, and when I run it on the build server (Ubuntu Precise) it runs fine, but when I run it on my mac I get "illegal option -- t". The command that has problems is simple, it's just a call to find:

find -type f -not -path [...]

On testing I have discovered that it is the -type option that has trouble on my Mac. If I run instead:

find ./ -type f -not -path [...]

It works, yet both work (seemingly equivalently) on the Linux box. Therefore my question is, are there significant differences between OSX's (BSD) find binary and the Linux (GNU?) find and will my modification to the script (adding the ./ path at the start) break anything that I haven't discovered yet?

GTF
  • 8,031
  • 5
  • 36
  • 59

1 Answers1

13

The standard mandates the path (./ in your example) to be mandatory. find on MacOS follows the standard.

GNU find (the one available on Linux) allows the path to be optional. If not specified, the current directory is assumed to be the path. On Linux, man find says

find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

(note that path is specified within [...] denoting that it is optional.

It is a good practice to specify the path.

devnull
  • 118,548
  • 33
  • 236
  • 227
  • Ok thanks, I've updated the script to include the path, but I wasn't sure if I was missing some more fundamental syntax differences. – GTF Jul 09 '13 at 13:52
  • 1
    There may be other differences, but they'll mostly be differences in the options and tests they support -- for example, OS X's find supports `-Bmin`, `-Bnewer`, and `-Btime` tests that check the file creation date (inode "birth time"), which linux doesn't have; on the other hand, OS X's find doesn't support the `-D debugopts` option. But if the same find command runs without error on both it'll generally do the same thing on both... – Gordon Davisson Jul 09 '13 at 15:48