title: Using bash, generating arguements for the linux find command by a FOR loop, causes errors
body: <p>As part of a larger script, I am trying to loop through an array of directories to apply a single linux <strong>find</strong> command. I am trying to make 1 single call to <strong>find</strong> because I want to pipe the output to some other commands.</p>
  <p>Attempt 1 - Without escaping quotes:</p>
  <pre><code># No escape
  COLORS=('purple' 'royal blue')
  FIND_ARGS=
  
  for C in &quot;${COLORS[@]}&quot;;
  do
      echo &quot;C is $C&quot;
      FIND_ARGS+=&quot;'${C}' &quot;
      
  done
  echo &quot;Arguments for find: $FIND_ARGS&quot;
  find $FIND_ARGS -type f    ## I even tried putting $FIND_ARGS in quotes here but that acts like a single file 
  
  ## OUTPUT:
  # C is purple
  # C is royal blue
  # Arguments for find: 'purple' 'royal blue'
  # find: '\'purple\'': No such file or directory
  # find: '\'royal': No such file or directory
  # find: 'blue\'': No such file or directory
  </code></pre>
  <p>With Escapes:</p>
  <pre><code>FIND_ARGS=
  # With Escape
  for C in &quot;${COLORS[@]}&quot;;
  do
      echo &quot;C is $C&quot;
      FIND_ARGS+=&quot;\'${C}\' &quot;    ## Changed original code here to include escapes
      
  done
  echo &quot;Arguments for find: $FIND_ARGS&quot;
  find $FIND_ARGS -type f
  
  ## OUTPUT:
  # C is purple
  # C is royal blue
  # Arguments for find: \'purple\' \'royal blue\'
  # find: '\\\'purple\\\'': No such file or directory
  # find: '\\\'royal': No such file or directory
  # find: 'blue\\\'': No such file or directory
  </code></pre>
  <p>Simple working command run from bash prompt:</p>
  <pre><code>## Working Template:
  find &quot;purple&quot; &quot;royal blue&quot; -type f
  
  # Output:
  # All files in both directories
  </code></pre>
  <p>I am pretty new to bash scripting. Is there a special way that I should be calling this? I looked at the man page for find to see if there is a flag that I need to set, but its rather large, so I could have easily missed it.</p>
  <p><strong>Resolution</strong>
  There is no need for the loop. The shell works with the array itself:</p>
  <pre><code>find &quot;${COLORS[@]}&quot; -type f
  </code></pre>