Take the 2-minute tour ×

I'm trying to get the following find command to work via NSTask:

find /Users/user/projects ! -path '*.git*' -ctime -1

However I am having trouble to get the ignore path part to work. In terminal it works fine. I get the modified files of the last 24 hrs excluding the .git directories. When using NSTask, the .git directories are not ignored, resulting in way too many positives...... I am using the following args:

NSArray *args = @[@"/Users/user/projects", @"!", @"-path", @"'*.git*'", @"-ctime", @"-1"];

Does anybody know what I am doing wrong?

share|improve this question
Why dont you try applescript for the same? –  Anoop Vaidya Dec 8 '12 at 17:39

2 Answers 2

up vote 1 down vote accepted

I think you have to replace the argument




otherwise find will ignore only files that are named '*.git*' (verbatim). Note that the shell removes the single quotes when you execute the command in the Terminal.

share|improve this answer

You may also find it easier to do.

NSString *argString = @"/Users/user/projects ! -path '*.git*' -ctime -1";
[nsTaskName setArguments: [argString componentsSeparatedByString: @" "]];

When you debug your arguments in terminal you can do just do a copy and past and add 'find ' in front of it.

share|improve this answer
Thats won't fix the '.git' vs .git problem I had, but I see what you mean. –  P5ycH0 Jan 21 '13 at 8:35
Right, I should have stated that as well lol. Was just trying to help you in the future as well. –  Richard Williamson Jan 21 '13 at 8:39

Your Answer


