title: get the first 5 characters from each line in shell script
body: <p>Here is my <strong>sample.txt</strong> file it contains following</p>
  
  <pre><code>31113    70:54:D2 - a-31003
  31114    70:54:D2 - b-31304
  31111    4C:72:B9 - c-31303
  31112    4C:72:B9 - d-31302
  </code></pre>
  
  <p>I have to write the shell script in that I am passing first 5 characters (eg 31113) as input id to other script. For this I have tried this </p>
  
  <pre><code>#!/bin/sh
  filename='sample.txt'
  filelines=`cat $filename`
  while read -r line
  do
    id= cut -c-5 $line
    echo $id
    #code for passing id to other script file as parameter
  done &lt; "$filename"
  </code></pre>
  
  <p>but it is not working this gives me error as</p>
  
  <pre><code>cut: 31113: No such file or directory
  cut: 70:54:D2 No such file or directory
  31114
  31111
  31112
  : No such file or directory
  </code></pre>
  
  <p>How can I do this?</p>