title: Groovy: How to execute complex shell command in groovy?
body: <p>I would like to be able to execute a nested shell command.  For example;</p>
  
  <pre><code>final String cmd = 'for i in pom.xml projects.xml; do find . -name $i | while read fname; do echo $fname; done;done'
  </code></pre>
  
  <p>I had tried the following syntax but wasn't able to get it running.</p>
  
  <ol>
  <li><code>def result = cmd.execute();</code></li>
  <li><code>def result = ['sh', '-c', cmd].execute();</code></li>
  <li><code>def result = ('sh -c for i in pom.xml projects.xml; do find . -name $i | while read fname; do echo $fname; done;done').execute()</code></li>
  </ol>
  
  <p>I would appreciate the help here.</p>