Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude sub directories from find: why is -not -path not working?

java -jar ~/Downloads/simian-2.3.35/bin/simian-2.3.35.jar files $(find ~/App/Classes/ -type f -name "*.m"  -not -path  "Lib/excludethisdir/*")

I'm trying to run simian and pass a file argument into it, but excluding a directory just isn't working. The Lib directory is contained in Classes

Can anyone point out why it's not working (The command runs, but it doesn't exclude)

like image 239
Killian Avatar asked Aug 07 '14 17:08

Killian


People also ask

How do I search a sub folder?

To search for files in File Explorer, open File Explorer and use the search box to the right of the address bar. Tap or click to open File Explorer. Search looks in all folders and subfolders within the library or folder you're viewing.

How do I exclude folders from Git repository?

You can create a .gitignore file in your repository's root directory to tell Git which files and directories to ignore when you make a commit. To share the ignore rules with other users who clone the repository, commit the .gitignore file in to your repository.

How do I find a subdirectory in Windows?

Open Windows Explorer. Select Organize / Folder and Search options. Select the Search Tab. In the How to search section, select the Include subfolders in search results when searching in file folders option.


1 Answers

You nested find command should be:

find ~/App/Classes/ -type f -name "*.m"  -not -path "./Lib/excludethisdir/*"

i.e. add ./ before your excluded path.

Or even better:

find ~/App/Classes/ -path "./Lib/excludethisdir/*" -prune -o -type f -name "*.m" -print
like image 86
anubhava Avatar answered Oct 11 '22 00:10

anubhava