p=['sh','-c','ls -l | sort'].execute()
println p.text
This is mostly cross-platform (assuming CygWin) and is nicely succinct.
I like this method over using the Groovy Groosh module as suggested by Yuri Schimke if only because it doesn't require an import:
def f = gsh.find('.', '-name', '*.java', '-ls');
f.pipeTo(lines);
As always there are many ways to skin the same cat.

0 comments:
Post a Comment