Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Another method of file copying via the Terminal UNIX
I tried to copy most of my disk from my internal HD to an external Firewire using the Finder in X. It seemed to be slow, slowing down the system too, and error prone on files with special characters in their names. So I went and did the following:
  1. Open up Terminal

  2. Change into the directory you want to copy:
    cd /dir/to/copy/from
  3. Execute this command:
    find . -print | cpio /place/where/you/want/to/copy
I found this to be a lot more reliable. It does not slow the system down, and copies absolutly everything, whereas tar may not.

[Editor's note: I haven't used cpio, and I'm not sure what it may or may not do with files which contain resource forks.]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,433 views]  

Another method of file copying via the Terminal | 4 comments | Create New Account
Click here to return to the 'Another method of file copying via the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
cpio
Authored by: peyote on Jun 29, '02 11:35:25AM
Note:-


  • cpio (like most of the Unix-derived utils) is unaware of resource forks and HSFS+ metadata, so these won't be copied. It does have the advantage over some other Unix utils though in that it does the right thing with (eg) device nodes.

  • You need at least one argument (in this case -p) to say "read the list of filenames to copy from stdin".

  • A common idiom is "find . -print | cpio -pmduv /dest". Those arguments mean read files from stdin, reset the modification on the copied files, create new directories as needed, copy unconditionally (otherwise cpio will ignore a file if the destination exists and is newer) and be verbose.

  • Also useful is the 'l' flag, which instead of copying the files will create hard links (not symlinks) between the source and destination files if they are on the same filesystem (handy if you want multiple copies of a source tree, say to build for multiple architectures).


All in all, a very handy and powerful tool but not really for the faint hearted.

For people not 100% comfortable at the command line, if you just want to copy a directory tree then "cp -R" is going to be more useful 9 times out of 10.

Pete.

[ Reply to This | # ]
cpio
Authored by: exonic on Jun 29, '02 03:45:07PM

This is a unix command, part of the GNU fileutils I believe. man cpio should tell u exactly what it does. Yes, I agree it is a better way of copying file, especially when you are attempting to copy symbolic links, where as cp will just follow the links unless told otherwise via the command. For people who aren't comfortable w/ the console.. GET COMFORABLTE!!!!



[ Reply to This | # ]
no resource forks
Authored by: DavidRavenMoon on Jun 29, '02 12:53:26PM

This wont copy the file's resource forks, if it has any, so some files and applications may not open after copying.

[ Reply to This | # ]

no resource forks
Authored by: DanFrakes on Jun 29, '02 10:30:04PM

Why not just use "ditto" -- which does copy resource forks?



[ Reply to This | # ]