I want to copy text files and only text files from src/ to dst/
src/
dst/
groovy:000> \"cp src/*.txt dst/\".execute().text ===> groovy:000> <
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 ...'"