I am using Bash to go through some directories and files. I am using find function as shown in the example and I need to exclude all directories (and all it includes) and files which name match some regular expression (which can be anything).
while read file
do
do_stuff "${file}"
done <<< "$(find ${SOME_DIR}")
I already tried using -not -name args but that only excluded that one specific directory, and processed all in that directory.
Btw. I found some similar questions in here, but all are quite specific. This regular expression can be really anything.
example: REGEX='^bbb$'
dir structure: ./test
├── bbb
│ └── some file
├── -e
├── dir2
│ └── bbb
├── a
├── b
└── c
So here I would like find to exclude bbb directory and all thats in it and bbb file.
Another regex example: '^.b.$' -- all files and directories that has b in their name