Reputation: 1621
Already we know that,
def total_cmd = ("less test.txt").execute() | ("wc -l").execute()
total_cmd.waitFor()
println total_cmd.getText()
How can i do this from a list of n
commands like,
def cmd_list = [ "cmd1".execute(), "cmd2".execute(),....,"cmdn".execute()]
Upvotes: 0
Views: 354
Reputation: 45309
You can execute, then reduce:
total_cmd = cmd_list*.execute().inject{a,b -> a | b}
This assumes a|b == b|a
Upvotes: 2