# finding files that are not registered as belonging to a port



## paulbeard (Jan 1, 2011)

I'd blame this on it being too early but my script-fu is not the best at any time of the day. 

What I am looking for is a way to walk through the /usr/local tree, find all the files therein, and check which ones are registered as part of a port. I don't install outside of the ports system so all the stuff in there should be owned by a port. I have been having a lot of problems with ports not upgrading cleanly due to dependencies not being met or other weirdness and I would like to get everything cleaned up without doing a massive delete and rebuild. 

If there is a tool/port that does this, I'm not aware of it. Where I am starting is: 


```
find . -type f -print | xargs -J% pkg_which % |
```

I can add a 
	
	



```
grep '?'
```
 after the pipe that will flag the presence of unowned files but I'm not clear on how to pass the name of the file from the find(1) command through the pipeline so that only files with a return value of ? are printed. 

Suggestions/dope slaps welcome. And if there is a tool that does this, I'd be glad to hear of it.


----------



## paulbeard (Jan 1, 2011)

And it looked it was solved already over here. 

Excellent.


----------

