我们已经知道了,
def total_cmd = ("less test.txt").execute() | ("wc -l").execute()
total_cmd.waitFor()
println total_cmd.getText()
如何从n
命令列表中执行此操作,
def cmd_list = [ "cmd1".execute(), "cmd2".execute(),....,"cmdn".execute()]
答案 0 :(得分:2)
您可以执行,然后减少:
total_cmd = cmd_list*.execute().inject{a,b -> a | b}
这假定为a|b == b|a