the cp (copy) command in linux
Hi,
I think there may be something wrong with the cp command (copy). I have a link pointing at nothing. It used to point at a file called "no" but that file is now gone. I wish to copy the link exactly as is, preserving ownership and timestamp. According to the Man page, cp -a should do this, however imagine my surprise when the timestamp changed. [root]# cp -a x.x y.y [root]# ls -lrt x.x lrwxrwxrwx 1 root root 2 Aug 14 17:28 x.x -> no [root]# ls -lrt y.y lrwxrwxrwx 1 root root 2 Aug 14 18:49 y.y -> no |
Hmmm - it worked on my FC4 box.
What distribution and kernel are you running? cat /etc/issue uname -a It may be you have an old binutils that needs to be updated. Also type "which cp" to see where it is finding the cp command. If it shows an alias that may be your issue. If it shows a file then type "file <pathto/cp> to verify it is a binary rather than a script. |
Quote:
Linux bk1.localdomain 2.6.20-1.2320.fc5 #1 Tue Jun 12 18:50:38 EDT 2007 i686 i686 i386 GNU/Linux [root]# cat /etc/issue Fedora Core release 5 (Bordeaux) Kernel \r on an \m I installed FC5 from a CD then did yum update kernel. I have also tried it calling /bin/cp directly - it is a binary. [root]# file /bin/cp /bin/cp: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped |
Set timestamp on a link (that's not pointing at anything)
Ok...
Is there a way to set a timestamp on a link? Basically I just need to get the mtime on the copy to be the same as the mtime on the original... any suggestions ?? :scratch: |
You might also look in /~/.bashrc or some such file to see if cp is aliased in some fashion.
For instance $ which ls ... on my system returns: /bin/ls ... no suggestion of trickery, ... ...but /~/.bashrc contains the line: alias ls='ls --color=auto' Big difference. |
hi rickh,
it was aliased to "cp -i" but it shouldn't matter - and i tried calling /bin/cp directly as well. maybe i can forget cp and just set the link somehow?? touch doesn't seem to work either... ??? [root]# touch -c -m -t 200708141750 y.y [root]# ls -lrt y.y lrwxrwxrwx 1 root root 2 Aug 14 20:27 y.y -> no |
Quote:
Kubuntu 8.04 Did you find a work around ? |
From the GNU manual at http://www.gnu.org/software/coreutil...vocation.html:
Quote:
Brian |
All times are GMT -5. The time now is 09:29 PM. |