title: Bash substring with pipes and stdin
body: <p>My goal is to cut the output of a command down to an arbitrary number of characters (let's use <strong>6</strong>). I would like to be able to append this command to the end of a pipeline, so it should be able to just use stdin.</p>
  
  <pre><code>echo "1234567890" | your command here 
  # desired output: 123456
  </code></pre>
  
  <p>I checked out <code>awk</code>, and I also noticed bash has a <code>substr</code> command, but both of the solutions I've come up with seem longer than they need to be and I can't shake the feeling I'm missing something easier.</p>
  
  <p>I'll post the two solutions I've found as answers, I welcome any critique as well as new solutions!</p>
  
  <hr>
  
  <p>Solution found, thank you to all who answered!</p>
  
  <p>It was close between jcollado and Mithrandir - I will probably end up using both in the future. Mithrandir's answer was an actual substring and is easier to view the result, but jcollado's answer lets me pipe it to the clipboard with no EOL character in the way.</p>