[Bash] find Command Exclude Sub-directory


Use find command to find all HTML files in a directory, but exclude the HTML files in some sub-directory.

Quesion

Find all HTML files in output directory, but exclude the HTML files in output/extra and output/tag sub-directories.

Answer

find output/ -not \( -path "output/extra/*" -o -path "output/tag/*" \) -name "*.html"

Tested on: Ubuntu Linux 16.04, find (GNU findutils) 4.7.0-git


References:

[1]