title: Convert time from dd/mm/yyyy hh:mm:ss to unix timestamp in bash script
body: <p>I have browsed through the similar threads and they helped me come closest to what I want to do but didn't fully answer my question. </p>
  
  <p>I have a date in the format <code>dd/mm/yyyy hh:mm:ss</code> (<code>$mydate = 26/12/2013 09:42:42</code>) that I want to convert in unix timestamp via the command:</p>
  
  <pre><code>date -d $mydate +%s
  </code></pre>
  
  <p>But here the accepted format is this one: <code>yyyy-mm-dd hh:mm:ss</code></p>
  
  <p>So I did this transformation: </p>
  
  <pre><code>echo $mydate| awk -F' ' '{printf $1}'| awk -F/ '{printf "%s-%s-%s\n",$3,$2,$1}'
  </code></pre>
  
  <p>And have this ouput:</p>
  
  <pre><code>2013-12-26
  </code></pre>
  
  <p>Which is good, now I try to append to hour part before doing the conversion:</p>
  
  <pre><code>echo $mydate| awk -F' ' '{printf $1; $hour=$2}'| awk -F/ '{printf "%s-%s-%s %s\n",$3,$2,$1,$hour}'
  </code></pre>
  
  <p>But then I have this: </p>
  
  <pre><code>2013-12-26 26/12/2013
  </code></pre>
  
  <p>It seem to not keep the variable <code>$hour</code>.</p>
  
  <p>I am new in awk, how could I do this ?</p>