I want to pass a generated argument array (or string) to a find command in bash, but everything I tried doesn't work. It seems to be something with the quoting, but I don't know how to solve this.
Here is what I tried.
#!/bin/bash
path="/path/to/folders/"
excludes=()
excludes+=(" -not -path \"./cache/*\"")
excludes+=(" -not -path \"./tmp/*\"")
find $path -type f \( "${excludes[@]}" \) >test.txt
I just get this message find: Der Pfad muß vor dem Suchkriterium stehen: -not -path "./cache/*"