advanced patterns when using `find` with `-exec` and variable substitution in a Bash script
Hey everyone, I'm running into an issue that's driving me crazy. I've searched everywhere and can't find a clear answer. I'm working with an scenario with executing a command that finds files and then uses `-exec` to process them in a Bash script. The command works as expected when run directly in the terminal but behaves differently when embedded in the script. I'm trying to use the following command: ```bash find /path/to/directory -name '*.log' -exec grep -H 'behavior' {} \; ``` However, when I run the script, I get the following behavior: ``` find: missing argument to `-exec' ``` I suspect it might be related to how I'm handling the command substitution or quoting. I've tried using double quotes around the command and substituting the path with a variable, like this: ```bash LOG_DIR='/path/to/directory' find "$LOG_DIR" -name '*.log' -exec grep -H 'behavior' {} \; ``` This still results in the same behavior. I also attempted to run the command with a single log file instead of using `-exec`, and it works fine, which leads me to believe that the scenario lies within the `-exec` part. I've verified that there are indeed `.log` files in the specified directory. Can anyone guide to understand why this behavior is happening in the script and how to fix it? I'd really appreciate any guidance on this. This issue appeared after updating to Bash latest. Any pointers in the right direction?