[英]How to execute simply list of shell commands with pipe using Groovy?
我們已經知道
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()]
您可以執行,然后減少:
total_cmd = cmd_list*.execute().inject{a,b -> a | b}
假設a|b == b|a
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.