I've got a find command in a bash script that works, but when I try to break it into variables that get added together it no longer works correctly.
I'm not really looking for a better way of doing this, I'd like to understand what Bash is doing in this case as I'm very stumped at this.
# Works, prints ./config
find . -type f -name 'config' ! -path './.git*'
echo
pathVar="! -path './.git*'"
# Doesn't correctly ignore './.git/config'
find . -type f -name 'config' $pathVar
echo
# Doesn't work 'find: ! -path './.git*': unknown primary or operator'
find . -type f -name 'config' "$pathVar"
$pathVaris assumed to be a single argument. you may either useevalto execute a string as a command or better yet, run the complete commands using conditional checks to decide which command the execute.