Are you trying to exclude the contents of the specific directory /tmp/logs (which would only be a problem with the script you showed us if you were sitting in / when you invoked your script), or are you trying to exclude the contents of any directory logs that is located in a directory named tmp .
Either way a grep may be the easiest way to solve your problem:
I suggest that you read post #6 and decide whether you want to use:
find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) | grep -v '^./tmp/logs/' |
while IFS= read -r file
do : Do whatever you want to do with "$file"
done
or:
find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) | grep -v '/tmp/logs/' |
while IFS= read -r file
do : Do whatever you want to do with "$file"
done
based on your answer to the question I asked in post #6. If you really, really want to, you can change those suggestions to:
find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) -print | grep -v '^./tmp/logs/' |
while IFS= read -r file
do : Do whatever you want to do with "$file"
done
or:
find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) -print | grep -v '/tmp/logs/' |
while IFS= read -r file
do : Do whatever you want to do with "$file"
done
respectively, and get exactly the same results with more typing. (In cases where you do not specify any primaries to find that produce output (such as -exec , -ok , or -print ), find supplies a -print primary by default.)
I sincerely apologize for assuming that you would realize that I was just suggesting a couple of possible replacements for your find command (based on your answer to the question about what files you are trying to exclude) in your pipeline. Based on the title of this thread, I didn't realize that I needed to repeat and improve the rest of your pipeline as well.