Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Mac `find` and Linux `find` [closed]

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?

like image 629
GTF Avatar asked Jul 09 '13 13:07

GTF


People also ask

What is the difference between macOS and Linux?

Linux is an open-source operating system, so users do not need to pay money to use to Linux. Mac OS is a product of Apple Company; it is not an open-source product, so to use Mac OS, users need to pay money then the only user will be able to use it.

Are Linux and Mac commands same?

The command line functionality on Mac and Linux are indeed similar as OS X has a flavour of UNIX (called Darwin) underneath the GUI that you see. The default shell on OS X is bash, so if you're familiar with that you will adjust nicely. On a Mac, the default command line application is Terminal.

What is the difference between Mac terminal and Linux terminal?

In general, both will have the same core commands and features (especially those defined in the Posix standard), but a lot of extensions will be different. For example, linux systems generally have a useradd command to create new users, but OS X doesn't.

What is the difference between Mac Windows and Linux?

MAC is similar when it comes to Malware. Windows is expensive, and the cost starts from $100. Linux is free, and anyone can download and use it. MAC is costlier than Windows, and the user is forced to buy a MAC system built by Apple.


1 Answers

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.

like image 64
devnull Avatar answered Sep 25 '22 12:09

devnull