# Help translating Linux a find command statement to FreeBSD 7.2



## IT_Architect (Mar 4, 2013)

I'm attempting to deploy a script to scan for changed files and scan them.  This is a Linux script that I've been trying to get to work and searched here and around the web.  I get syntax errors using the [CMD="find"] -wholename[/CMD] right out of the gate with 7.2.  How can I change this to work with FreeBSD 7.2?


```
#!/usr/local/bin/bash

# Log location
LOG=/var/log/clamav/scan.log
# .....
find / -not -wholename '/sys/*' -and -not -wholename '/proc/*' -mmin -61 -type f -print0 | xargs -0 -r clamscan --exclude-dir=/proc/ --exclude-dir=/sys/ --quiet --infected --log=${LOG}
```

Thanks!


----------



## SirDice (Mar 4, 2013)

FreeBSD 7.2 has been end-of-life since June 2010.

http://www.freebsd.org/security/#unsup


----------



## IT_Architect (Mar 4, 2013)

SirDice said:
			
		

> FreeBSD 7.2 has been end-of-life since June 2010.
> http://www.freebsd.org/security/#unsup


I know.  I'm working on an older system that won't be upgraded for a short time yet.

Thanks!


----------



## wblock@ (Mar 4, 2013)

Old versions of FreeBSD find(1) do not have the -wholename option.  Later ones, like in 8.x, add that as a synonym for -path.

Was the dash on -61 intentional?


----------



## IT_Architect (Mar 4, 2013)

wblock@ said:
			
		

> Old versions of FreeBSD find(1) do not have the -wholename option.  Later ones, like in 8.x, add that as a synonym for -path


  Yes, that's why I'm asking here.  I'm sure things would be easier if I were working with a newer version of FreeBSD.



			
				wblock@ said:
			
		

> Was the dash on -61 intentional?


It is the unmodified code that works on Linux.  It means modified or created less than 61 minutes ago.

Thanks!


----------



## Carpetsmoker (Mar 5, 2013)

-wholename seems to be the same thing as -path. From my CentOS 5 manpage:

```
-path pattern
              See -wholename.   The predicate -path is also  supported  by  HP-UX
              find.
```

And from my FreeBSD 9 manpage:

```
-wholename pattern
       The same thing as -path, for GNU find compatibility.
```


And a free complimentary example for verification:

```
[~/test]% find .
.
./dir1
./dir1/asdasd
./dir2
./dir2/afasf

[~/test]% find . -not -path './dir1*'
.
./dir2
./dir2/afasf
```


----------



## IT_Architect (Mar 5, 2013)

Carpetsmoker said:
			
		

> -wholename seems to be the same thing as -path.


It is, it's a synonym added for GNU compatibility.  If you don't have wholename, you don't have path. 

What I did do is write two nice, portable scripts, one for scanning with ClamAV daily that does the entire server, and another for scanning for a user definable modification date period, say hourly, and where you can easily change which directories you want scanned without touching the code.

Thanks!


----------



## Carpetsmoker (Mar 5, 2013)

Ack, I only now read that the answer had already been given. Must have missed that 

Anyhow,



> If you don't have wholename, you don't have path.



The -path option should be available in FreeBSD 7.2, only the -wholename is a GNU extention. -path has been available since forever and is part of POSIX (unlike -wholename).

You can also use -regex


```
[~/test]% find . -not -regex '\./dir1.*'
.
./dir2
./dir2/afasf
```


----------



## fonz (Mar 5, 2013)

IT_Architect said:
			
		

> It is the unmodified code that works on Linux.  It means modified or created less than 61 minutes ago.


That works with FreeBSD as well:
`% find . -mmin 61` means *exactly* 61 minutes ago.
`% find . -mmin [b]-[/b]61` means *less than* 61 minutes ago.
`% find . -mmin [b]+[/b]61` means *more than* 61 minutes ago.


----------



## IT_Architect (Mar 5, 2013)

Carpetsmoker said:
			
		

> -path has been available since forever


WOW!  I looked for that, and it was hidden in plain site.  That makes me wrong about if wholename is not available, neither is path available".  Not true as evidenced in the FreeBSD manual.  The thing is, when I used -path, it comes back with invalid option errors.
*Edit*:  Man do I have to eat crow on this one!  I took the stock script and simply substituted -path for -wholename, and it worked perfectly!  Oh duh!

Thanks TONS!


			
				fonz said:
			
		

> That works with FreeBSD as well


I was asked that question and explained to someone else further up the thread.  I do use that.

Thanks!


----------

