groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Fouts <>
Subject Running a shell script with return value?
Date Wed, 30 May 2018 17:57:21 GMT
Inside groovy, I want to write a shell script that parses the output of
some shell command and get some string value back. How can I get the value
of the shell command?

For example say I want to get the file size of some_file, I'll do

x = sh returnStatus: true, script: '''
  IFS=" " read -ra LINE <<< `ls -al | grep some_file`
  echo ${LINE[4]}

How can I store the value of ${LINE[4]} in a groovy variable to use later?


View raw message