Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On linux, the default find command ((GNU findutils) 4.4.2 on my system) has an optional path parameter, which defaults to current directory (the common case). From man page:

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

On OSX, find does not have an optional path parameter:

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

I find this quite annoying. Has anyone solved this issue with a clever command alias/shell function, or perhaps by installing a different version of find?

share|improve this question

migrated from Jan 16 '13 at 20:16

This question came from our site for professional and enthusiast programmers.

This is completely OT for SO, but historically find always required a path - it became optional in Linux but that is by no means standard. Typically you just type . for the path when searching from the current directory, e.g. find . -name foo.txt. – Paul R Jan 16 '13 at 16:19
@PaulR sorry, I wasn't sure if this would be OT or not. I found some other questions asking about command line usage. Maybe they were old, before other stack exchange domains went up. Where would this belong? – michalmocny Jan 16 '13 at 17:49
up vote 1 down vote accepted

OS X uses BSD find, which has historically required a path. You can install GNU findutils via MacPorts or the like.

share|improve this answer
Or create a simple shell script... – weberc2 Jan 16 '13 at 21:13
Why a shell script when a function will do? – Ignacio Vazquez-Abrams Jan 16 '13 at 21:31
brew install findutils installed gfind which I could alias. Thanks! – michalmocny Jan 16 '13 at 22:22
@IgnacioVazquez-Abrams because it doesn't necessitate installing MacPorts or something similar. – weberc2 Jan 17 '13 at 14:29
You don't need to install anything to have functions; they're part of bash. – Ignacio Vazquez-Abrams Jan 17 '13 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .