find using -prune and -size
I can't seem to get find to use both -prune and -size together. I want to find files over a certain size and at the same time exclude certain directories.
I'm able to do one or the other but not both simultaneously. To find files of a certain size I use this in a bash script. Code:
find $1 -user $USER -type f -size +600k -exec ls -lh {} \; Code:
find $1 -user $USER -type f -size +100k -path $1/.snapshot -prune -o -print -exec ls -lh {} \; What am I doing wrong? |
By default, find combines its arguments using AND. And since AND binds more tightly than OR, your statement is not doing what you think it is.
|
You need to put prune before the other tests and precede the other tests with -o. The -prune option prevents decending the directory and returns true.
Here is an example which excludes the ./udev directory: Code:
find ./ \( -path './udev' -prune \) -o -type f -name "*.war" -print Here I'll locate all "*.war" files excluding both ./udev and ./webarchives directories: Code:
find ./ \( -path './udev' -o -path './webarchives' \) -prune -o -type f -name "*.war" -print |
Quote:
|
Code:
find ./ \( -path './udev' -o -path './webarchives' \) -prune -o -type f -name "*.war" -print Code:
if (path == "./udev" || path == "./webarchives") { Code:
((path == "./udev" ||path == "./webarchives") && prune) || |
All times are GMT -5. The time now is 11:59 AM. |