title: Bash read file line by line and use awk
body: <p>I have a sample.txt file in <strong>Username:Firstname:Lastname:Telephone number</strong> format (with several lines, and I want to create a script that converts every line into this format:</p>
  
  <pre><code>uid: Username
  cn: LastnameFirstname
  sn: Firstname
  tel:Telephone number
  </code></pre>
  
  <p>So far I've managed to create the citire function that reads and prints OK only if the sample.txt has one line.</p>
  
  <pre><code>citire () {
  uid=$1
  l=$2
  while read -r line
  do
   name=$line
    if [ -z "$3" ]
    then
    echo -e "$uid:`echo $name|awk -F  ":" '{print $"'$l'"}'`"
    else
    l2=$3
    echo -e "$uid: `echo $name|awk -F  ":" '{print $"'$l'" $"'$l2'"}'`"
   fi
   done &lt; /home/alexandrumohora/teste/sample.txt  
  }
  
  citire uid 1
  citire cn 3 2
  citire sn 2
  citire tel 4
  </code></pre>
  
  <p>Can you please tell me what should I modify to make it print each record (line of the file) at a time?</p>
  
  <p>Thank you!</p>