我希望能够执行嵌套的shell命令.例如;
final String cmd = 'for i in pom.xml projects.xml; do find . -name $i | while read fname; do echo $fname; done;done'
Run Code Online (Sandbox Code Playgroud)
我尝试了以下语法,但无法让它运行.
def result = cmd.execute();def result = ['sh', '-c', cmd].execute();def result = ('sh -c for i in pom.xml projects.xml; do find . -name $i | while read fname; do echo $fname; done;done').execute()我很感激这里的帮助.