3
find . -iname '*.rar' -execdir ls {} +

this will not work under OSX Lion, yielding ls: blabla.rar: No such file or directory etc..

Additionally, above will work under Linux. However, it will invoke ls as many times as it find result. Tested with simple cat $# script.

So I see 2 problems with -execdir

  • under Linux it will NOT combine search result as stated in manual when using {} +
  • under OSX it will NOT change directory as stated in manual, again using {} +

Wanted to confirm that this is buggy and not my misunderstanding.

2 Answers 2

3

I don't know about Mountain Lion, but it's a known bug in GNU findutils, apparently fixed in the 4.5 branch (check your find --version). See https://savannah.gnu.org/bugs/?19593

There is also this bug: https://savannah.gnu.org/bugs/?29949 in find version 4.5.9, which matches the Mountain Lion symptom. Perhaps you should check both version numbers.

Sign up to request clarification or add additional context in comments.

2 Comments

Sounds like same symptoms, tried with pwd originally, not changing directory. Not even sure how to check findutil version on Lion... --version doesn't work.
@Pablo if it doesn't respond to --version, it's not GNU find; it could well be FreeBSD find. I no longer have either a Mac or a FreeBSD box handy, so I can't help you there, but you could try Googling for FreeBSD bug reports.
0

On Linux does it execute ls once for every file or once for every sub-directory? From man find (GNU findutils version 4.4.2):

As with the -exec action, the ‘+’ form of -execdir will build a command line to process more than one matched file, but any given invocation of command will only list files that exist in the same subdirectory.

2 Comments

I've just tried on Linux to put files under same sub-directory. Still I see echo $# will give me one invocation per file, nothing is combined.
find . -iname "*.asd" -execdir test.sh {} + is the test script. test.sh contains echo $#.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.