title: Linux How to copy symbolic link and preserve date
body: <p>I have a directory with this kind of file: </p>
  
  <pre><code>  0 lrwxrwxrwx  1 utges_m gid36     12 May 17  2011 libedit.so -&gt; libedit.so.2
    0 lrwxrwxrwx  1 utges_m gid36     16 Apr 16  2009 libedit.so.2 -&gt; libedit.so.2.0.9
  352 -rw-r--r--  1 utges_m gid36 358958 Mar 10  2010 libedit.so.2.0.9
  </code></pre>
  
  <p>I would like to copy file and symlink and preserve date.</p>
  
  <p>I started with this command:</p>
  
  <pre><code>  cp -dp sourceDir/* destinationDir
  </code></pre>
  
  <p>and the result is:</p>
  
  <pre><code>  0 lrwxrwxrwx  1 siri gid33     12 Jul  9 16:38 libedit.so -&gt; libedit.so.2
    0 lrwxrwxrwx  1 siri gid33     16 Jul  9 16:38 libedit.so.2 -&gt; libedit.so.2.0.9
  356 -rw-r--r--  1 siri gid33 358958 Mar 10  2010 libedit.so.2.0.9
  </code></pre>
  
  <p>So, I wrote this simple bash script:</p>
  
  <pre><code> cp -dp $OLDDIR/* $NEWDIR
  
   ls $OLDDIR | while read f; do {
      TS=$(stat -c '%Y' "$OLDDIR/$f")
      DATE=$(date -d "UTC 1970-01-01 $TS secs")
      echo "$f  $DATE"
      touch -d "${DATE}" "$NEWDIR/$f"
   } done;
  </code></pre>
  
  <p>The script output is:</p>
  
  <pre><code> libedit.so  Tue May 17 21:35:14 CEST 2011
   libedit.so.2  Thu Apr 16 10:30:05 CEST 2009
   libedit.so.2.0.9  Wed Mar 10 16:31:17 CET 2010
  </code></pre>
  
  <p>but unfortunately the result is:</p>
  
  <pre><code>  0 lrwxrwxrwx  1 siri gid33     12 Jul  9 16:55 libedit.so -&gt; libedit.so.2
    0 lrwxrwxrwx  1 siri gid33     16 Jul  9 16:55 libedit.so.2 -&gt; libedit.so.2.0.9
  356 -rw-r--r--  1 siri gid33 358958 Mar 10  2010 libedit.so.2.0.9
  </code></pre>
  
  <p>What's wrong with what I did?</p>
  
  <p>I'm using Red Hat Enterprise Linux ES release 4 (Nahant Update 3)</p>