title: Making code generic
body: <p>I have one script <strong>/location/centers_password.sh</strong> in which I have below lines of code :</p>
  
  <pre><code>if [ "$DC" = "sl" ]
  then
      arg1=`echo -n $Center|wc -m`
      if [ $arg1 -gt 3 ]
      then
          grep "^$Center" /location/.CenterPassword.file.sdi.sl
          grep "^$Center" /location/.CenterPassword_xel.file.sdi.sl
      else
           grep "^$Center" /location/.CenterPassword.file.sl
           grep "^$Center" /location/.CenterPassword_xel.file.sl
           grep "^$Center" /location/.sftpPasswod.file.sl
      fi
  elif [ "$DC" = "ch" ]
  then
      arg1=`echo -n $Center|wc -m`
      if [ $arg1 -gt 3 ]
      then
          grep "^$Center" /location/.CenterPassword.file.sdi.ch
          grep "^$Center" /location/.CenterPassword_xel.file.sdi.ch
      else
           grep "^$Center" /location/.CenterPassword.file.ch
           grep "^$Center" /location/.CenterPassword_xel.file.ch
           grep "^$Center" /location/.sftpPasswod.file.ch
      fi
  </code></pre>
  
  <p>What I am doing here is, when I execute this code it reads the datacenter name .CenterPassword.file.sdi.ch file. If I explain more, suppose the datacenter starts from 'sl' it reads .CenterPassword.file.sdi.sl file and fetch the password and suppose datacenter starts from 'ch' it reads .CenterPassword.file.sdi.ch and fetch the password.</p>
  
  <p>My requirement is to make this code generic. This file should read the hostname and if the hostname's initial two letter match with <strong>.CenterPassword.file.sdi.ch</strong> file last two letters (in this example, should match with 'ch') it should fetch the password. Please help to do this.</p>