title: Bash script to tail -f with colored lines
body: <p>I tried to create a script from <a href="https://unix.stackexchange.com/a/8417/5731">this suggestion</a> like this :</p>
  
  <pre><code>#!/bin/bash
  
  if [ $# -eq 0 ]; then
          tail -f /var/log/mylog.log
  fi
  
  
  if [ $# -eq 1 ]; then
          tail -f /var/log/mylog.log | perl -pe 's/.*$1.*/\e[1;31m$&amp;\e[0m/g'
  fi
  </code></pre>
  
  <p>It shows black tail of the file when I pass no arguments to the script, but every line is red when I pass an argument. I would like it to color only lines which contain the word passed to the script.</p>
  
  <p>For example, this would color lines containing word "info" :</p>
  
  <pre><code>./color_lines.sh info
  </code></pre>
  
  <p>How to change the script to work with one argument?</p>