title: Can't append file extension to array of string in Bash - Terminal Mac OSx
body: <p>I have this CSV with 2 column: one contains names and the other file names with no extension. </p>
  
  <p>When I parse it and store the values in 2 array I'd like to add a path and PDF extension to the file names but when I do it, I get something like this:</p>
  
  <pre><code>Giacomos-MBP:test Jack$ ./test.sh -p e.csv -a 2017
  .pdf://www.test.com/2017/03cr14a076d
  .pdf://www.test.com/2017/03bg15a365d
  .pdf://www.test.com/2017/03bs15a451d
  .pdf://www.test.com/2017/03bg15a440d
  .pdf://www.test.com/2017/03cr16a570d
  .pdf://www.test.com/2017/03bg15a794d
  </code></pre>
  
  <p>I expect </p>
  
  <pre><code>http://www.test.com/2017/03bg15a794d.pdf
  </code></pre>
  
  <p>instead</p>
  
  <p>Anybody knows why? It looks like the extension goes in front of the path </p>
  
  <p>This is my script</p>
  
  <pre><code>#!/bin/bash
  
  while getopts p:a: arg
  do
      case $arg in
          p) multi=$OPTARG 
              ;;
          a) anno=$OPTARG
              ;;
      esac
  done
  
  declare -a citta
  declare -a codice
  i=0
  
  while IFS=";" read col1 col2 do
  
      citta[$i]=$col1;
      codice[$i]=$col2;
      ((i++))
  
  done &lt; $multi
  
  
  cartella='http://www.test.com/'$anno'/'
  total=${#citta[*]}
  
  
  for (( i=0; i&lt;=$(( $total -1 )); i++ )) do
  
      last="${codice[$i]}.pdf"
      echo $cartella$last
  
  done
  </code></pre>
  
  <p>As @FredrikPihl has suggested this is the output I get</p>
  
  <pre><code>Giacomos-MBP:test Jack$ ./test.sh -p e.csv -a 2017
  + getopts p:a: arg
  + case $arg in
  + multi=e.csv
  + getopts p:a: arg
  + case $arg in
  + anno=2017
  + getopts p:a: arg
  + declare -a citta
  + declare -a codice
  + i=0
  + IFS=';'
  + read col1 col2
  + citta[$i]=Agnadello
  + codice[$i]=$'03cr14a076d\r'
  + (( i++ ))
  + IFS=';'
  + read col1 col2
  + citta[$i]=Arcene
  + codice[$i]=$'03bg15a365d\r'
  + (( i++ ))
  + IFS=';'
  + read col1 col2
  + citta[$i]=Artogne
  + codice[$i]=$'03bs15a451d\r'
  + (( i++ ))
  + IFS=';'
  + read col1 col2
  + citta[$i]=$'\r'
  + codice[$i]=
  + (( i++ ))
  + IFS=';'
  + read col1 col2
  + total=4
  + cartella=http://www.test.com/2017/
  + (( i=0 ))
  + (( i&lt;=3 ))
  + last=$'03cr14a076d\r.pdf'
  + echo $'http://www.test.com/2017/03cr14a076d\r.pdf'
  .pdf://www.test.com/2017/03cr14a076d
  + (( i++  ))
  + (( i&lt;=3 ))
  + last=$'03bg15a365d\r.pdf'
  + echo $'http://www.test.com/2017/03bg15a365d\r.pdf'
  .pdf://www.test.com/2017/03bg15a365d
  + (( i++  ))
  + (( i&lt;=3 ))
  + last=$'03bs15a451d\r.pdf'
  + echo $'http://www.test.com/2017/03bs15a451d\r.pdf'
  .pdf://www.test.com/2017/03bs15a451d
  + (( i++  ))
  + (( i&lt;=3 ))
  Giacomos-MBP:test Jack$ 
  </code></pre>