Carl Wilhelm Soderstrom wrote: > > > The basic algorithm for to copy in a _file_ (not a directory, pipe, et al) is: > > > > read $i # actually, this is the cpio header data (inode info) for the > > # file, which is followed in a cpio archive by the file itself > > if [ -e $i ] > > then rm -f $i > ^^^^^ > > wait a second here! cpio is supposed to *copy* files, not *move* > them. the man page repeatedly uses the word 'copy', and never mentions > anything about 'delete'. > Yeah, but at the most basic level, the existing file must be removed before a new one with the same name can be put in its place. > > fi > > cat input > $i # the file size is in the cpio header > > > > Note that in your last cpio example (the one where the file disappears), > > your sources for the copy are also your target. > > ok. bad example. but it holds even when the source is in a tree > adjacent to the current directory: > > chrome at steel:/var/tmp/test$ dir > total 8.0k > drwxr-xr-x 2 chrome chrome 4.0k Aug 5 08:13 ./ > drwxrwxrwt 4 root root 4.0k Aug 5 06:26 ../ > -rw-r--r-- 1 chrome chrome 0 Aug 5 08:12 file1 > -rw-r--r-- 1 chrome chrome 0 Aug 5 08:13 file2 > -rw-r--r-- 1 chrome chrome 0 Aug 5 08:13 file3 > -rw-r--r-- 1 chrome chrome 0 Aug 5 08:13 file4 > chrome at steel:/var/tmp/test$ cd - > /var/tmp/try > chrome at steel:/var/tmp/try$ find ../test/|cpio -padmuv . > ./../test/ > cpio: ../test/file1: No such file or directory > cpio: ../test/file2: No such file or directory > cpio: ../test/file3: No such file or directory > cpio: ../test/file4: No such file or directory > 0 blocks > chrome at steel:/var/tmp/try$ dir /var/tmp/test/ > total 8.0k > drwxr-xr-x 2 chrome chrome 4.0k Aug 5 08:13 ./ > drwxrwxrwt 4 root root 4.0k Aug 5 06:26 ../ > > Carl Soderstrom This is actually the same situation. When you do a "find ../test/" on the left side of the pipe you get: ../test ../test/file1 ../test/file2 ../test/file3 ../test/file4 Note the "../" part here, okay? Note also that "./" is identical to "." Now, pipe the command into " | cpio -pdumva .", which basically is the same thing as applying that copyin routine above. The targets now become: ./../test ./../test/file1 ./../test/file2 ./../test/file3 ./../test/file4 Since the source file "../test/file1" _is_ the target "./../test/file1", once again, "./../test/file1" is removed before it can be written. The directory isn't removed because copying a directory with "cpio -pdumva" is basically a "mkdir" followed by a "touch". BTW: Note that if instead, you had done: cd /var/tmp/test find . -print | cpio -pdumva ../test you'd have gotten what you expected. Hope this helps'idly, -S