Not sure if I understand your question.
Do you mean to make system calls and process the results?
If so, you can simply do something like:
println 'cat /Users/tim_yates/.bash_profile'.execute().text
To print the contents of a file
You can also process the output of the process:
def proc = 'cat /Users/tim_yates/.bash_profile'.execute() | 'grep git'.execute() println proc.text
If you want to retrieve File text using standard Groovy API calls, you can do:
println new File( '/Users/tim_yates/.bash_profile' ).text
And this gets a list of lines in the file, finds everything that contains the word git , then prints each of them in turn:
new File( '/Users/tim_yates/.bash_profile' ).text.tokenize( '\n' ).findAll { it.contains 'git' }.each { println it }
source share