# find help



## balanga (Feb 25, 2018)

I've been trying to figure out how to use find(1) to search for specific files...

According to the man page:


```
SYNOPSIS
     find [-H |    -L | -P] [-EXdsx] [-f path] path ... [expression]
     find [-H |    -L | -P] [-EXdsx] -f path [path    ...] [expression]
```

so I should be able to supply several paths with the '-f'  parameter, but I should also be able to use:


```
OPERATORS
     The primaries may be combined using the following operators.  The opera-
     tors are listed in    order of decreasing precedence.

     ( expression )
         This evaluates to true if the parenthesized expression evaluates
         to    true.

     ! expression
     -not expression
         This is the unary NOT operator.  It evaluates to true if the
         expression    is false.
```

so I want to search from '.' but exclude tmp, which I thought I should be able to do using 

`-f  . !tmp`

but can't stumble upon the correct syntax. Is what I'm trying to do possible?

There is an example of the NOT operator:


```
find / \! -name "*.c" -print
         Print out a list of all the files whose names do not end in .c.
```


----------



## scottro (Feb 25, 2018)

Does this help?
https://www.cyberciti.biz/faq/linux-unix-osx-bsd-find-command-exclude-directories/


----------



## balanga (Feb 25, 2018)

scottro  I tried the example in the link....


```
find /path/to/dest -type d \( ! -name tmp \) -print
```

but get:-


```
find: (!: unkown primary or operator
```

So maybe the example shown requires a specific shell or maybe it is for GNU find rather  than BSD find....


----------



## scottro (Feb 25, 2018)

That's too bad.  That site often has FreeBSD solutions as well.  

https://lists.freebsd.org/pipermail/freebsd-questions/2012-December/247556.html 

Has 
	
	



```
find / -type f -not -path '/extra/*'
```
I just tried it, and it didn't give an error.  Otherwise, I would say just google FreeBSD find command exclude directory and see what comes up.


----------

