user3741611
user3741611

Reputation: 327

groovy ant execute with pipeTo

I am trying to use awk with pipeTo and need help with syntax.

this works:

def myId = 'myid'
print "ls -al".execute().pipeTo("grep ${myId}".execute()).text

this fails:

print "ls -al".execute().pipeTo('awk \'{print $2}\''.execute()).text
print "ls -al".execute().pipeTo('''awk '{print $2}' '''.execute()).text

Upvotes: 1

Views: 241

Answers (1)

Will
Will

Reputation: 14539

You may want to try removing the space between print and \$1:

p1="ls -la".execute()
p2='awk {print\$1}'.execute()
p1 | p2
p2.waitFor()
print p2.text

Note p2.err.text would contain error messages, if any (useful if p2.text is blank).

Upvotes: 1

Related Questions