title: How to get the output of a shell script in a Jenkinsfile?
body: <p>In a Jenkinsfile Groovy script stage, say I want to issue a linux command that outputs rows and columns of strings, and want to get the nth column in the output of a certain row. An example of such command is "ls -al." So I do this correct?</p>
  
  <pre><code>stage("Get dir size") {
    sh returnStatus: true, script: '''
      LINE=`ls -al | grep some_dir`
      IFS=" " read -ra COLS &lt;&lt;&lt; $LINE
      echo ${COLS[4]}
    '''
    /* I want to use the value of ${COL[4]} after above block */
  }
  </code></pre>
  
  <p>But how do I get the value of essentially ${COL[4]}, which is the fifth column in an "ls -al" command, which is the directory size?</p>
  
  <p>Thanks!</p>