title: How to use regex with cut at the command line?
body: <p>I have some output like this from <code>ls -alth</code>:</p>
  
  <pre><code>drwxr-xr-x    5 root    admin   170B Aug  3  2016 ..
  drwxr-xr-x    5 root    admin    70B Aug  3  2016 ..
  drwxr-xr-x    5 root    admin     3B Aug  3  2016 ..
  drwxr-xr-x    5 root    admin     9M Aug  3  2016 ..
  </code></pre>
  
  <p>Now, I want to parse out the <code>170B</code> part, which is obviously the size in human readable format.  I wanted to do this using <code>cut</code> or <code>sed</code>, because I don't want to use tools that are any more complicated/difficult to use than necessary.</p>
  
  <p>Ideally I want it to be robust enough to handle the <code>B</code>, <code>M</code> or <code>K</code> suffix that comes with the size, and multiply accordingly by <code>1</code>, <code>1000000</code> and <code>1000</code> accordingly.  I haven't found a good way to do that, though.</p>
  
  <p>I've tried a few things without really knowing the best approach:</p>
  
  <pre><code>ls -alth | cut -f 5 -d \s+
  </code></pre>
  
  <p>I was hoping that would work because I'd be able to just delimit it on <em>one or more spaces</em>.  </p>
  
  <p>But that doesn't work.  How do I supply <code>cut</code> with a regex delimiter?  or is there an easier way to extract only the size of the file from <code>ls -alth</code>?</p>
  
  <p>I'm using CentOS6.4</p>