title: Bash how can rename a file saved into a variable?
body: <p>how can I do this:</p>
  
  <p>I have a file, <code>eval.txt</code> saved into a variable, that I want to rename <code>timestamp_eval.txt</code></p>
  
  <pre><code>filetosend=/home/cft/eval.txt
  filename=$(echo $filetosend | cut -d '/' -f4) //to get only the name
  DATE=$(date +%Y%m%d)
  filename=${DATE}_${filename} //add timestamp to name
  </code></pre>
  
  <p>how can I rename <code>$filetosend</code> ?</p>
  
  <p>I found this solution:</p>
  
  <pre><code>DATE=(date +%Y%m%d)
  mydir=$(echo $(dirname $a))
  myfile=$(echo $(basename $a))
  myfile=${DATE}_${myfile}
  filetosend=$mydir/$myfile
  cp $a $filetosend
  </code></pre>