Groovy execute “cp *” shell command

前端 未结 2 599
Happy的楠姐
Happy的楠姐 2021-02-01 23:49

I want to copy text files and only text files from src/ to dst/

groovy:000> \"cp src/*.txt dst/\".execute().text       
===> 
groovy:000> 
<         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 00:01

    Wildcard expansion is performed by the shell, not by cp (or groovy). Your first example is trying to copy a file named *. You could make your command "sh -c 'cp ...'"

提交回复
热议问题